This walkthrough will show you two methods of using CloudTruth to pass environment variables to a Docker container. The first method installs the CloudTruth CLI directly in your docker image, the second method uses a CloudTruth environment file with docker run.
Run your tutorial Docker image and pass in the CloudTruth API key to allow CloudTruth to authenticate in the container instance. This will print your CloudTruth Parameters and container environment variables.
docker run -it --rm -e CLOUDTRUTH_API_KEY="YOUR_API_KEY" tutorial
You can also export the CloudTruth API key to your local environment and then pass the key into the container without specifying the key value.
docker run -it --rm -e CLOUDTRUTH_API_KEY tutorial
Method 2: Docker Environment File
You can also use CloudTruth Parameters inside a Docker container by using Docker run --env-file and passing parameters with the cloudtruth parameter export docker CloudTruth CLI command from your local environment.
You can create an environment file with the CloudTruth CLI.
The dotenv file can now be passed to Docker with the --env-file flag. This will pull down an alpine container, issue the printenv command and display your CloudTruth parameters and container environment variables.
docker run -it --rm --env-file dotenv alpine printenv
This can also be accomplished in a single line using Bash substitution and embedding the CloudTruth CLI command directly in Docker run.