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.

  • Running 32bit LXC on 64 bit host machine?
  • how to set /sys/kernel/mm/transparent_hugepage/enabled to 'never' on coreos
  • What exactly is a Docker repository?
  • Why do I get 'could not resolve “registry.giantswarm.io”' errors from boot2docker?
  • Operate/control host hardware from within docker container
  • Move session specific data between diff app versions on the fly
  • 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?

  • How to show all users in dockers group?
  • UnknownHostException in Kubernetes-Container
  • Migration of docker image from AWS to Bluemix or Azure
  • Docker usage in compose/swarm mode
  • How to test docker image with external script
  • NodeJS/Dokku/Docker: ffmpeg exited with code 127
  • 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.