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.

  • Cron containers for docker - how do they actually work?
  • How to use Docker for Dev env
  • Heroku docker:release: Expected response to be successful, got 422
  • consul-template using Address not ServiceAddress in template
  • Raspberry PI docker container not starting
  • Can I run multiple programs in a Docker container?
  • 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?

  • connecting to AWS server where docker is deployed through template
  • REST request across networks
  • docker run local script without host volumes
  • Unable to run docker node.js application
  • doing a docker build for the first time and ran into this massive error
  • Accessing apache2 residing inside Docker container from Host machine web browser
  • 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_HOST=tcp://
    set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\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.