Docker Community Forums

Share and learn in the Docker community.

Passing environment variables to Docker Daemon


(Cristoforo) #1

Generally speaking, how can I have docker daemon use environment variables?

In my specific scenario I need to pass the AWS credentials to the docker daemon in order to configure the awslogs log-driver.

What I get with a basic test such as:
docker -D run --rm -it --log-driver=awslogs --log-opt awslogs-region=eu-west-1 --log-opt awslogs-group=test-group --log-opt awslogs-stream=hello-world hello-world

is

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Failed to initialize logging driver: NoCredentialProviders: no valid providers in chain. Deprecated.
        For verbose messaging see aws.Config.CredentialsChainVerboseErrors.

While the AWS credentials are available as environment variables (the aws cli works like a charm), the docker daemon is not using them. Any ideas?


My current configuration from docker version:
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:15:28 2016
OS/Arch: windows/amd64

Server:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 21:15:28 2016
OS/Arch: linux/amd64


(Michael Friis) #2

You can configure daemon.json in Docker for Windows: https://docs.docker.com/docker-for-windows/#/docker-daemon

Details here: https://docs.docker.com/engine/reference/commandline/dockerd/#/daemon-configuration-file

I don’t know for certain whether it’ll work for you use though.

Out of curiosity, why do you want to log to AWS from Docker for Windows?


(Cristoforo) #3

Hi Michael,
already tried that way - not working. If I add the AWS credential to the JSON, docker gives an error when restarting.
As far as I understand only a predefined list of variables can be configured through the JSON:

My goal is to have my container logs published in AWS Cloudwatch (I’m using Windows as development environment)