Docker Machine command memo

Docker Machine commands

item version
docker-machine v0.12.2
VirtualBox 6.1.4

From creating Docker Machine to stopping

Create

The machine name to be created is "test-box".

$ docker-machine create --driver virtualbox test-box

Check the list

$ docker-machine ls
NAME          ACTIVE   DRIVER       STATE     URL                         SWARM                DOCKER      ERRORS 
test-box      -        virtualbox   Running   tcp://192.168.99.110:2376                        v19.03.12       

Activate

$ eval $(docker-machine env test-box)
$ docker-machine ls
NAME          ACTIVE   DRIVER       STATE     URL                         SWARM                DOCKER      ERRORS 
test-box      *        virtualbox   Running   tcp://192.168.99.110:2376                        v19.03.12      

Connect with SSH and log out with exit

$ docker-machine ssh test-box
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net

docker@test-box:~$ exit
logout

IP address confirmation

$ docker-machine ip test-box
192.168.99.110

Deactivate

$ docker-machine ls
NAME          ACTIVE   DRIVER       STATE     URL                         SWARM                DOCKER      ERRORS 
test-box      *        virtualbox   Running   tcp://192.168.99.110:2376                        v19.03.12 
$ eval $(docker-machine env -u)
$ docker-machine ls
NAME          ACTIVE   DRIVER       STATE     URL                         SWARM                DOCKER      ERRORS 
test-box      -        virtualbox   Running   tcp://192.168.99.110:2376                        v19.03.12 

Stop Docker machine

$ docker-machine stop test-box
Stopping "test-box"...
Machine "test-box" was stopped.

Run container on Docker Machine

Execute docker command on Docker Machine

If you run a docker command while DockerMachine is active, you are running the command on the host of the active DockerMachine. The following is running an nginx container on the active test-box, a Docker Machine host. After execution, when you access port number 8000 of the IP address of the test-box host from a browser (192.168.99.110: 8000), the "Welcome to nginx!" Screen is displayed.

$ docker-machine ls
NAME          ACTIVE   DRIVER       STATE     URL                         SWARM                DOCKER      ERRORS 
test-box      *        virtualbox   Running   tcp://192.168.99.110:2376                        v19.03.12 
$ docker run -d -p 8000:80 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
852e50cd189d: Pull complete 
a29b129f4109: Pull complete 
b3ddf1fa5595: Pull complete 
c5df295936d3: Pull complete 
232bf38931fc: Pull complete 
Digest: sha256:c3a1592d2b6d275bef4087573355827b200b00ffc2d9849890a4f3aa2128c4ae
Status: Downloaded newer image for nginx:latest
054e2f9af619f68c12dfa964772dcb9902ebfeed9c5805122dd4a967b87b88f7

Confirmation of created container

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
054e2f9af619        nginx               "/docker-entrypoint.…"   2 hours ago         Up 9 minutes        0.0.0.0:8000->80/tcp   boring_chatelet

Enter the shell of the container on the Docker Machine host

$ docker exec -it 054e2f9af619 bash                              
root@054e2f9af619:/# 

Recommended Posts

Docker Machine command memo
Docker command memo
docker memo
Docker command
docker tutorial (memo)
Docker operation memo
Docker command list
docker basic command
[Memo] docker summary
Docker command summary
Docker-compose command memo
Docker command memorandum
[Docker] Command summary
[Docker] Command list
Environment construction command memo with Docker on AWS
Docker x Rails 6 (memo)
Docker Machine (personal memorandum)
docker inspect --format memo
docker error delete command
docker command personal summary
Docker command cheat sheet
Command memo to install xeyes in ubuntu docker environment
Decomposing the Docker run command. .. ..
Redmine (Docker) environment construction memo
Docker Compact Manual (1: Basic / Basic Command)
Installing and building Docker (memo)
Docker execution memo summarized for myself
docker
nft command memo of nf_tables (CentOS8)
Easy installation of Docker with snap (1 command)
Grant docker command execution permission to ec2-user
Try to use docker command without sudo.
Install Docker with WSL2 Memo ([Part 2] Docker introduction)