Docker Machine – Commandes utiles

DOCKER-MACHINE

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

Create and manage machines running Docker.

Version: 0.15.0, build b48dc28d

Author:
  Docker Machine Contributors - 

Options:
  --debug, -D						Enable debug mode
  --storage-path, -s "/home/adminsys/.docker/machine"	Configures storage path [$MACHINE_STORAGE_PATH]
  --tls-ca-cert 					CA to verify remotes against [$MACHINE_TLS_CA_CERT]
  --tls-ca-key 						Private key to generate certificates [$MACHINE_TLS_CA_KEY]
  --tls-client-cert 					Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT]
  --tls-client-key 					Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY]
  --github-api-token 					Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN]
  --native-ssh						Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH]
  --bugsnag-api-token 					BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN]
  --help, -h						show help
  --version, -v						print the version
  
Commands:
  active		Print which machine is active
  config		Print the connection config for machine
  create		Create a machine
  env			Display the commands to set up the environment for the Docker client
  inspect		Inspect information about a machine
  ip			Get the IP address of a machine
  kill			Kill a machine
  ls			List machines
  provision		Re-provision existing machines
  regenerate-certs	Regenerate TLS Certificates for a machine
  restart		Restart a machine
  rm			Remove a machine
  ssh			Log into or run a command on a machine with SSH.
  scp			Copy files between machines
  mount			Mount or unmount a directory from a machine with SSHFS.
  start			Start a machine
  status		Get the status of a machine
  stop			Stop a machine
  upgrade		Upgrade a machine to the latest version of Docker
  url			Get the URL of a machine
  version		Show the Docker Machine version or a machine docker version
  help			Shows a list of commands or help for one command
  
Run 'docker-machine COMMAND --help' for more information on a command.

 

DOCKER-MACHINE ACTIVE

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

Print which machine is active

Options:
   
   --timeout, -t "10"	Timeout in seconds, default to 10s

 

Afficher la machine Docker active :

docker-machine active

ex :

$ docker-machine active
manager

 

DOCKER-MACHINE CONFIG

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

Print the connection config for machine

Description:
   Argument is a machine name.

Options:
   
   --swarm	Display the Swarm config instead of the Docker daemon

 

Afficher la configuration de connexion d’une machine Docker :

docker-machine config machine

ex :

$ docker-machine config manager
--tlsverify
--tlscacert="C:\\Users\\DarwinOS\\.docker\\machine\\machines\\manager\\ca.pem"
--tlscert="C:\\Users\\DarwinOS\\.docker\\machine\\machines\\manager\\cert.pem"
--tlskey="C:\\Users\\DarwinOS\\.docker\\machine\\machines\\manager\\key.pem"
-H=tcp://192.168.99.101:2376

 

DOCKER-MACHINE CREATE

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

Create a machine

Description:
   Run 'docker-machine create --driver name --help' to include the create flags for that driver in the help text.

Options:
   
   --driver, -d "virtualbox"										Driver to create machine with. [$MACHINE_DRIVER]
   --engine-env [--engine-env option --engine-env option]						Specify environment variables to set in the engine
   --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]	Specify insecure registries to allow with the created engine
   --engine-install-url "https://get.docker.com"							Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL]
   --engine-label [--engine-label option --engine-label option]						Specify labels for the created engine
   --engine-opt [--engine-opt option --engine-opt option]						Specify arbitrary flags to include with the created engine in the form flag=value
   --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]		Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR]
   --engine-storage-driver 										Specify a storage driver to use with the engine
   --swarm												Configure Machine to join a Swarm cluster
   --swarm-addr 											addr to advertise for Swarm (default: detect and use the machine IP)
   --swarm-discovery 											Discovery service to use with Swarm
   --swarm-experimental											Enable Swarm experimental features
   --swarm-host "tcp://0.0.0.0:3376"									ip/socket to listen on for Swarm master
   --swarm-image "swarm:latest"										Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]
   --swarm-join-opt [--swarm-join-opt option --swarm-join-opt option]					Define arbitrary flags for Swarm join
   --swarm-master											Configure Machine to be a Swarm master
   --swarm-opt [--swarm-opt option --swarm-opt option]							Define arbitrary flags for Swarm master
   --swarm-strategy "spread"										Define a default scheduling strategy for Swarm
   --tls-san [--tls-san option --tls-san option]							Support extra SANs for TLS certs
   --virtualbox-boot2docker-url 									The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL]
   --virtualbox-cpu-count "1"										number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT]
   --virtualbox-disk-size "20000"									Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]
   --virtualbox-host-dns-resolver									Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER]
   --virtualbox-hostonly-cidr "192.168.99.1/24"								Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR]
   --virtualbox-hostonly-nicpromisc "deny"								Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC]
   --virtualbox-hostonly-nictype "82540EM"								Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE]
   --virtualbox-hostonly-no-dhcp									Disable the Host Only DHCP Server [$VIRTUALBOX_HOSTONLY_NO_DHCP]
   --virtualbox-import-boot2docker-vm 									The name of a Boot2Docker VM to import [$VIRTUALBOX_BOOT2DOCKER_IMPORT_VM]
   --virtualbox-memory "1024"										Size of memory for host in MB [$VIRTUALBOX_MEMORY_SIZE]
   --virtualbox-nat-nictype "82540EM"									Specify the Network Adapter Type [$VIRTUALBOX_NAT_NICTYPE]
   --virtualbox-no-dns-proxy										Disable proxying all DNS requests to the host [$VIRTUALBOX_NO_DNS_PROXY]
   --virtualbox-no-share										Disable the mount of your home directory [$VIRTUALBOX_NO_SHARE]
   --virtualbox-no-vtx-check										Disable checking for the availability of hardware virtualization before the vm is started [$VIRTUALBOX_NO_VTX_CHECK]
   --virtualbox-share-folder 										Mount the specified directory instead of the default home location. Format: dir:name [$VIRTUALBOX_SHARE_FOLDER]
   --virtualbox-ui-type "headless"									Specify the UI Type: (gui|sdl|headless|separate) [$VIRTUALBOX_UI_TYPE]

 

Créer une machine Docker pour VirtualBox:

docker-machine create --driver drivername machine

ex :

$ docker-machine create --driver "virtualbox" manager
Running pre-create checks...
Creating machine...
(manager) Copying C:\Users\DarwinOS\.docker\machine\cache\boot2docker.iso to C:\Users\DarwinOS\.docker\machine\machines\manager\boot2docker.iso...
(manager) Creating VirtualBox VM...
(manager) Creating SSH key...
(manager) Starting the VM...
(manager) Check network to re-create if needed...
(manager) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(manager) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Program Files\Docker Toolbox\docker-machine.exe env manager
$ docker-machine create --driver "virtualbox" --virtualbox-memory=2048 --virtualbox-disk-size=5000 node1
Running pre-create checks...
Creating machine...
(node1) Copying C:\Users\DarwinOS\.docker\machine\cache\boot2docker.iso to C:\Users\DarwinOS\.docker\machine\machines\node1\boot2docker.iso...
(node1) Creating VirtualBox VM...
(node1) Creating SSH key...
(node1) Starting the VM...
(node1) Check network to re-create if needed...
(node1) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(node1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Program Files\Docker Toolbox\docker-machine.exe env node1
$ docker-machine create --driver digitalocean --digitalocean-access-token=${TOKEN} node1
$ docker-machine create --driver digitalocean --digitalocean-access-token=${TOKEN} --digitalocean-region=lon1 --digitalocean-size=1gb node1
$ docker-machine create --driver amazonec2 --amazonec2-access-key=${ACCESS_KEY_ID} --amazonec2-secret-key=${SECRET_ACCESS_KEY} node1
$ docker-machine create --driver amazonec2 --amazonec2-access-key=${ACCESS_KEY_ID} --amazonec2-secret-key=${SECRET_ACCESS_KEY} --amazonec2-region=eu-west-1 --amazonec2-ami=ami-ed82e39e --amazonec2-instance-type=t2.large node1
$ docker-machine create --driver hyperv --hyperv-virtual-switch "DMSwitch" node1

Pour les autres hyperviseurs ou hébergeurs Cloud, voir Docker docs – Machine drivers :

  • amazonec2
  • azure
  • digitalocean
  • generic
  • hyperv
  • openstack
  • rackspace
  • virtualbox
  • […]

 

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

 

DOCKER-MACHINE INSPECT

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

Inspect information about a machine

Description:
   Argument is a machine name.

Options:
   
   --format, -f 	Format the output using the given go template.

 

Afficher les informations détaillées relatives à une machine Docker :

docker-machine inspect machine

ex :

$ docker-machine inspect manager
{
    "ConfigVersion": 3,
    "Driver": {
        "IPAddress": "192.168.99.101",
        "MachineName": "manager",
        "SSHUser": "docker",
        "SSHPort": 50545,
[...]
    },
    "DriverName": "virtualbox",
    "HostOptions": {
        "Driver": "",
        "Memory": 0,
        "Disk": 0,
[...]
$ docker-machine inspect manager -f 'Addresse IP : {{.Driver.IPAddress}}'
Addresse IP : 192.168.99.101

 

DOCKER-MACHINE IP

Commande : docker-machine ip
Usage: docker-machine ip [arg...]

Get the IP address of a machine

Description:
   Argument(s) are one or more machine names.

 

Afficher l’adresse IP d’une machine Docker :

docker-machine ip machine

ex :

$ docker-machine ip manager
192.168.99.101

 

DOCKER-MACHINE LS

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

List machines

Options:
   
   --quiet, -q					Enable quiet mode
   --filter [--filter option --filter option]	Filter output based on conditions provided
   --timeout, -t "10"				Timeout in seconds, default to 10s
   --format, -f 				Pretty-print machines using a Go template

 

Afficher la liste des machines Docker :

docker-machine ls

ex :

$ 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 MOUNT

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

Mount or unmount a directory from a machine with SSHFS.

Description:
   Arguments are [machine:][path] [mountpoint]

Options:
   
   --unmount, -u	Unmount instead of mount

 

Monter un dossier d’une machine Docker sur une autre :

docker-machine mount machine:/path/to/machinerep hostrep

ex :

$ mkdir foo
$ docker-machine ssh dev mkdir foo
$ docker-machine mount dev:/home/docker/foo foo
$ touch foo/bar
$ docker-machine ssh dev ls foo
bar

 

DOCKER-MACHINE PROVISION

Commande : docker-machine provision
Usage: docker-machine provision machine [machine...]

Re-provision existing machines

 

Reprovisionner les machines Docker existantes :

docker-machine provision machine [machine...]

ex :

$ docker-machine provision node1 node2
Waiting for SSH to be available...
Waiting for SSH to be available...
Detecting the provisioner...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

 

DOCKER-MACHINE REGENERATE-CERTS

Commande : docker-machine regenerate-certs
Usage: docker-machine regenerate-certs [OPTIONS] [arg...]

Regenerate TLS Certificates for a machine

Description:
   Argument(s) are one or more machine names.

Options:

   --force, -f          Force rebuild and do not prompt
   --client-certs       Also regenerate client certificates and CA.

 

Régénérer le certificat TLS d’une machine Docker :

docker-machine regenerate-certs machine

ex :

$ docker-machine env manager
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.102:2376": x509: certificate is valid for 192.168.99.101, not 192.168.99.102
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
$ docker-machine regenerate-certs manager
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
$ docker-machine env manager
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102: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)

 

DOCKER-MACHINE RESTART

Commande : docker-machine restart
Usage: docker-machine restart [arg...]

Restart a machine

Description:
   Argument(s) are one or more machine names.

 

Redémarrer une machine Docker :

docker-machine restart machine

ex :

$ docker-machine restart manager
Restarting "manager"...
(manager) Check network to re-create if needed...
(manager) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(manager) Waiting for an IP...
Waiting for SSH to be available...
Detecting the provisioner...
Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

 

DOCKER-MACHINE RM

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

Remove a machine

Description:
   Argument(s) are one or more machine names.

Options:
   
   --force, -f	Remove local configuration even if machine cannot be removed, also implies an automatic yes (`-y`)
   -y		Assumes automatic yes to proceed with remove, without prompting further user confirmation

 

Supprimer une machine Docker :

docker-machine rm machine

ex :

$ docker-machine rm manager
About to remove manager
WARNING: This action will delete both local reference and remote instance.
Are you sure? (y/n): y
Successfully removed manager

 

DOCKER-MACHINE SCP

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

Copy files between machines

Description:
   Arguments are [[user@]machine:][path] [[user@]machine:][path].

Options:
   
   --recursive, -r	Copy files recursively (required to copy directories)
   --delta, -d		Reduce amount of data sent over network by sending only the differences (uses rsync)
   --quiet, -q		Disables the progress meter as well as warning and diagnostic messages from ssh

 

Copier des fichiers entre machines Docker :

docker-machine scp machine:/path/to/machinerep/filename /path/to/hostrep
docker-machine scp machine:/path/to/machinerep/filename machine:/path/to/machinerep
docker-machine scp -r machine:/path/to/machinerep machine:/path/to/machinerep

ex :

$ cat foo.txt
cat: foo.txt: No such file or directory
$ docker-machine ssh dev pwd
/home/docker
$ docker-machine ssh dev 'echo A file created remotely! >foo.txt'
$ docker-machine scp dev:/home/docker/foo.txt .
foo.txt                                                           100%   28     0.0KB/s   00:00
$ cat foo.txt
A file created remotely!

 

DOCKER-MACHINE SSH

Commande : docker-machine ssh
Usage: docker-machine ssh [arg...]

Log into or run a command on a machine with SSH.

Description:
   Arguments are [machine-name] [command]

 

Se connecter en SSH à machine Docker ou exécuter une commande sur une machine Docker :

docker-machine ssh machine

ex :

$ docker-machine ssh manager
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 18.05.0-ce, build HEAD : b5d6989 - Thu May 10 16:35:28 UTC 2018
Docker version 18.05.0-ce, build f150324
docker@manager:~$
$ docker-machine ssh manager free
             total       used       free     shared    buffers     cached
Mem:       1019528     305564     713964     231348       5192     231580
-/+ buffers/cache:      68792     950736
Swap:      1154516          0    1154516
$ docker-machine ssh manager df -hT
Filesystem           Type            Size      Used Available Use% Mounted on
tmpfs                tmpfs         896.1M    225.9M    670.1M  25% /
tmpfs                tmpfs         497.8M         0    497.8M   0% /dev/shm
/dev/sda1            ext4           17.9G     44.8M     16.9G   0% /mnt/sda1
cgroup               tmpfs         497.8M         0    497.8M   0% /sys/fs/cgroup
c/Users              vboxsf        475.8G    202.8G    273.0G  43% /c/Users
/dev/sda1            ext4           17.9G     44.8M     16.9G   0% /mnt/sda1/var/lib/docker

 

DOCKER-MACHINE START

Commande : docker-machine start
Usage: docker-machine start [arg...]

Start a machine

Description:
   Argument(s) are one or more machine names.

 

Démarrer une machine Docker :

docker-machine start machine

ex :

$ docker-machine start manager
Starting "manager"...
(manager) Check network to re-create if needed...
(manager) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(manager) Waiting for an IP...
Machine "manager" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

 

DOCKER-MACHINE STATUS

Commande : docker-machine status
Usage: docker-machine status [arg...]

Get the status of a machine

Description:
   Argument is a machine name.

 

Afficher le statut d’une machine Docker :

docker-machine status machine

ex :

$ docker-machine status manager
Running

 

DOCKER-MACHINE STOP

Commande : docker-machine stop
Usage: docker-machine stop [arg...]

Stop a machine

Description:
   Argument(s) are one or more machine names.

 

Arrêter une machine Docker :

docker-machine stop machine

ex :

$ docker-machine stop manager
Stopping "manager"...
Machine "manager" was stopped.

 

DOCKER-MACHINE UPGRADE

Commande : docker-machine upgrade
Usage: docker-machine upgrade [arg...]

Upgrade a machine to the latest version of Docker

Description:
   Argument(s) are one or more machine names.

 

Mettre à jour une machine Docker avec la dernière version de Docker:

docker-machine upgrade machine

ex :

$ docker-machine upgrade manager
Waiting for SSH to be available...
Detecting the provisioner...
Upgrading docker...
Stopping machine to do the upgrade...
Upgrading machine "manager"...
Copying C:\Users\DarwinOS\.docker\machine\cache\boot2docker.iso to C:\Users\DarwinOS\.docker\machine\machines\manager\boot2docker.iso...
Starting machine back up...
(manager) Check network to re-create if needed...
(manager) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(manager) Waiting for an IP...
Restarting docker...

 

DOCKER-MACHINE VERSION

Commande : docker-machine version
Usage: docker-machine version [arg...]

Show the Docker Machine version or a machine docker version

 

Afficher la version d’une machine Docker :

docker-machine version machine

ex :

$ docker-machine version manager
18.05.0-ce

 

REFERENCES

Fermer le menu
%d blogueurs aiment cette page :