As the title says, whats the difference between running a command for a docker-machine as
eval $(docker-machine env mycontainer)
docker run httpd
And
docker $(docker-machine config mycontainer) run httpd
as both create an httpd image under the "mycontainer" ip, but with the second, there's no container shown with "docker ps"
In the first form, you are first evaluating a series of env vars (DOCKER_HOST
, DOCKER_CERT_PATH
, DOCKER_TLS_VERIFY
, DOCKER_MACHINE_NAME
) which are configuring your current shell so that any docker
command you later launch will talk to the same docker daemon.
In the second form, you are passing the params (--tlsverify
, --tlscacert
, --tlscert
, --tlskey
, -H
) directly to the docker
command. Those will eventually override the values already in your env or the defaults (i.e. connect to local daemon).
In this latest case if you want to see the container you just launched making sure your are talking to the correct server, you have to use the same command line parameters again with docker $(docker-machine config mycontainer) ps
To summarize:
config
is more suited for single on-spot commandsenv
is more convenient for a full session on the same server.