Commandes Linux : docker-machine env

DOCKER-MACHINE ENV

Commande : docker-machine env
Usage: docker-machine env [OPTIONS] [arg...]

Display the commands to set up the environment for the Docker client

Description:
   Argument is a machine name.

Options:
   
   --swarm	Display the Swarm config instead of the Docker daemon
   --shell 	Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, emacs], default is auto-detect
   --unset, -u	Unset variables instead of setting them
   --no-proxy	Add machine IP to NO_PROXY environment variable

 

Afficher les variables d’environnement relatives à une machine Docker :

docker-machine env machine

ex :

$ docker-machine env manager
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\DarwinOS\.docker\machine\machines\manager"
export DOCKER_MACHINE_NAME="manager"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env manager)

 

Rendre une machine Docker active (sous Linux):

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   -        virtualbox   Running   tcp://192.168.99.101:2376           v18.05.0-ce
$ eval $(docker-machine env manager)
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   *        virtualbox   Running   tcp://192.168.99.101:2376           v18.05.0-ce
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   -        virtualbox   Running   tcp://192.168.99.101:2376           v18.05.0-ce
$ docker-machine use manager
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   *        virtualbox   Running   tcp://192.168.99.101:2376           v18.05.0-ce

 

Rendre une machine Docker active (sous Windows):

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   -        virtualbox   Running   tcp://192.168.99.102:2376           v18.05.0-ce
$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env manager)
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   *        virtualbox   Running   tcp://192.168.99.102:2376           v18.05.0-ce
$ env | grep DOCKER
DOCKER_MACHINE_NAME=manager
DOCKER_CERT_PATH=C:\Users\DarwinOS\.docker\machine\machines\manager
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.102:2376
DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   -        virtualbox   Running   tcp://192.168.99.102:2376           v18.05.0-ce
$ docker-machine use manager
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.05.0-ce
manager   *        virtualbox   Running   tcp://192.168.99.102:2376           v18.05.0-ce
$ env | grep DOCKER
DOCKER_MACHINE_NAME=manager
DOCKER_CERT_PATH=C:\Users\DarwinOS\.docker\machine\machines\manager
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.102:2376
DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox

 

Supprimer les variables d’environnement pour cibler le démon local (--unset, -u):

$ docker-machine ls
NAME             ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default          *        virtualbox   Running   tcp://192.168.99.100:2376           v18.06.1-ce
swarm-manager    -        virtualbox   Stopped                                       Unknown
swarm-worker01   -        virtualbox   Stopped                                       Unknown
swarm-worker02   -        virtualbox   Stopped                                       Unknown
$ eval $(docker-machine env -u)
$ docker-machine ls
NAME             ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default          -        virtualbox   Running   tcp://192.168.99.100:2376           v18.06.1-ce
swarm-manager    -        virtualbox   Stopped                                       Unknown
swarm-worker01   -        virtualbox   Stopped                                       Unknown
swarm-worker02   -        virtualbox   Stopped
$ docker-machine ls
NAME             ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default          *        virtualbox   Running   tcp://192.168.99.100:2376           v18.06.1-ce
swarm-manager    -        virtualbox   Stopped                                       Unknown
swarm-worker01   -        virtualbox   Stopped                                       Unknown
swarm-worker02   -        virtualbox   Stopped                                       Unknown
$ docker-machine use -u
$ docker-machine ls
NAME             ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default          -        virtualbox   Running   tcp://192.168.99.100:2376           v18.06.1-ce
swarm-manager    -        virtualbox   Stopped                                       Unknown
swarm-worker01   -        virtualbox   Stopped                                       Unknown
swarm-worker02   -        virtualbox   Stopped

 

Fermer le menu