item | version |
---|---|
docker-machine | v0.12.2 |
VirtualBox | 6.1.4 |
The machine name to be created is "test-box".
$ docker-machine create --driver virtualbox 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
$ 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
$ docker-machine ssh test-box
( '>')
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-_--_-\) www.tinycorelinux.net
docker@test-box:~$ exit
logout
$ docker-machine ip test-box
192.168.99.110
$ 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
$ docker-machine stop test-box
Stopping "test-box"...
Machine "test-box" was stopped.
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
$ 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
$ docker exec -it 054e2f9af619 bash
root@054e2f9af619:/#
Recommended Posts