This document provides instructions for getting started with Docker and Docker Compose. It explains how to install Docker and Docker Compose, basic Docker commands like running containers and viewing logs, mapping ports, and using Docker Compose to define and run multi-container applications.
21. $ docker
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
$ docker
22. $ docker version
Client version: 1.62
Client API version: 1.18
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): darwin/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 4749651
$ docker version
27. $ docker run ubuntu:14.04 /bin/echo 'Hello world'
Hello world
$ docker run image execute [argument, …]
28. $ docker run -it ubuntu:14.04 /bin/bash
root@af8bae53bdd3:/#
$ docker run -‐it image execute [argument, …]
29. $ docker run -d ubuntu:14.04 /bin/echo
-c "while true; do echo hello world; sleep 1; done"
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147
$ docker run -‐d image execute [argument, …]
30. $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
1e5535038e28 ubuntu:14.04 /bin/sh… 2 minutes ago Up 1 minute insane_babbage
$ docker ps
31. $ docker logs 1e5535038e28
hello world
hello world
hello world
$ docker logs [container ID/Name]
32. $ docker logs insane_babbage
hello world
hello world
hello world
$ docker logs [container ID/Name]
54. $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 2 minutes ago EXITED(0) nginx_container
$ docker ps -‐a
56. $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 10 minutes ago Up 1 minute nginx_container
$ docker ps
58. $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 15 minutes ago Up 1 minute insane_babbage
$ docker ps
62. $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest a785ba7493fd 16 hours ago 132.9 MB
$ docker images
63. $ docker pull mysql:latest
latest: Pulling from mysql
7a3e804ed6c0: Pull complete
……
ff78d9bb5f46: Already exists
Status: Downloaded newer image for mysql:latest
$ docker pull image_name:tag
64. $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest a785ba7493fd 16 hours ago 132.9 MB
mysql latest ff78d9bb5f46 3 days ago 282.9 MB
$ docker images