Setting TLS opptions for Docker as Environment Variables

I’ve got the local docker daemon running using certificates and I can list all the running containers using the very long winded command like

docker --tlsverify --tlscacert=/path/ca.cer --tlscert=/path/client.cert --tlskey=/path/client.key -H=localhost:2376 ps

But when I run docker ps I get a bad certificate error since the various tls options from the above command are not passed to docker. I have spent a number of hours going through the docker website and can’t find any options on how to set them.

  • Building Docker image from Spring Boot Jar
  • How to change container configuration without Dockerfile?
  • docker website opens after a while - ec2/virtualbox
  • How to set up Hadoop in Docker Swarm?
  • Why do Docker overlay networks require consensus?
  • Docker-Machine and Swarm behind proxy
  • I have set DOCKER_CERT_PATH, but it doesn’t seem to work.
    Is there a DOCKER_CACERT environment variable that docker would read if --tlscacert is not specified?

  • Windows Server Containers domain account auth
  • Cannot change owner of Docker Volume directory to non-root user
  • Redis in docker starts/restarts multiple times?
  • Docker machine timeout - how to fix without destroying the machine?
  • Error in docker container bash: vi: command not found
  • Docker for Mac Beta: Unable to link containers properly
  • One Solution collect form web for “Setting TLS opptions for Docker as Environment Variables”

    Those options should be set in the docker daemon config file

    "tls": true,
    "tlsverify": true,
    "tlscacert": "",
    "tlscert": "",
    "tlskey": "",
    

    The --config-file option allows you to set any configuration option for the daemon in a JSON format.
    By default, docker tries to load a configuration file from /etc/docker/daemon.json on Linux and %programdata%\docker\config\daemon.json on Windows.

    On the client side, you need to set the docker-machine env variables:

    For instance:

    $ docker-machine.exe env --shell cmd dev
    set DOCKER_TLS_VERIFY=1
    set DOCKER_HOST=tcp://192.168.99.101:2376
    set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
    set DOCKER_MACHINE_NAME=dev
    # Run this command to configure your shell: copy and paste the above values into your command prompt
    

    (Replace dev with the name of your machine)

    Make sure DOCKER_CERT_PATH refers to a folder which includes your certificate.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.