Run CLI on Docker

◷ Reading Time: 5 minutes

FlexRule CLI has the capability to run as a Docker container.

There is an option to create a FlexRule CLI image and run a Docker container using the image in order to script and run CLI commands.

Install FlexRule CLI

1. Follow the resource page to silent-install FlexRule CLI

CLI Silent Install- FlexRule Resource Hub

Create Docker Volume

2.1 Install Docker

Follow these steps Install on Windows | Docker Documentation and switch to windows container mode.

2.2 Create volume

docker volume create [volume name]
  • [volume name]: You can list existing docker volume based on this name.

Once a volume is created, Docker creates a mount point that is accessible from both windows and docker.

Run the following command to get the docker volume mount point direction:

docker volume inspect [volume name]
  • [volume name]: the volume name which was created in the above step.

2.3 Copy data

Before you can run your FlexRule CLI command, you should copy the input data to the mount point, which includes all your required FlexRule packages, runtime assemblies, and FlexRule license files; So they would be accessible by docker image.

For the Command prompt, simply change the current directory to the mount point and copy your files.

Or use the File Browser to copy files. If you receive the error “Access denied” you can check your docker settings, or run the icacls command to grant directory access e.g.

icacls . /grant everyone:(OI)(CI)F /T

More information on icacls | Microsoft Learn

To use the CLI command, required files should be copied to the mount point
e.g. for “fr.exe publish”, your project directory, runtime folder, and FlexRule license should be copied

Create docker image

3. Create a docker image using the CLI application folder

In this step, we are going to create a FlexRule CLI docker image which contains all the necessary files to run CLI commands.

Change your current directory to the CLI installation folder and run the following command:

"docker build -t [docker image:tag] -f .\win-x64.dockerfile ."
  • [docker image: tag]: image name and image tag e.g frcli:latest
Run Docker FlexRule CLI

4. Run your FlexRule CLI command

After the image is created, we can run it using the following command:

docker run -v [volume name]:[win path] [docker image:tag] [CLI command]
  • [volume name]: the volume name which was created in the above step.
  • [win path]: non-existence windows path for docker side access.
  • [docker image: tag]: the image name/tag we created in the previous step
  • [CLI command]: CLI command to run e.g “fr.exe publish [options]”

Note that the mount point is addressed differently on the docker side; all the volume root paths should be replaced with a relative path

The below example runs the “fr.exe publish” command on the docker image; as you can see the mount point binds to a non-exist path “c:\frcli”

docker.exe run -v testVol:c:\frcli frcli:latest publish --project "c:/frcli/<YourProjectPath>" --destination C:/frcli/<OutputPackageFile> --profile "<Profile>" --includeassemblies true --packageidentifier <PackageID>--packageversion <PackageVersion> --serviceversion <ServiceVersion> --method Package --runtime "C:/frcli/<RuntimePath>"

The resulting file will be published to the mount directory.

Updated on December 6, 2022

Was this article helpful?

Related Articles