$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
scrapinghub/splash latest 4ddd2efcb0df 5 months ago 2.17GB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
➜ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c28ebaec5aeb hello-world "/hello" 18 seconds ago Exited (0) 17 seconds ago crazy_wiles
b1ff5faed1ca scrapinghub/splash "python3 /app/bin/sp…" 19 hours ago Exited (0) 16 hours ago amazing_zhukovsky
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b0497e57c41 scrapinghub/splash "python3 /app/bin/sp…" 3 minutes ago Up 3 minutes 0.0.0.0:5023->5023/tcp, 0.0.0.0:8050-8051->8050-8051/tcp boring_shtern
root@c4c6b6545289:/# ls
bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@c4c6b6545289:/# echo "This is a sample text" > a_sample.txt
root@c4c6b6545289:/# ls
a_sample.txt bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@c4c6b6545289:/# exit
exit
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fcc850c3e81a 831691599b88 "bash" 30 minutes ago Exited (130) 8 minutes ago condescending_banzai
c4c6b6545289 ubuntu "bash" 55 minutes ago Exited (0) 36 seconds ago eloquent_bohr
1b0497e57c41 scrapinghub/splash "python3 /app/bin/sp…" About an hour ago Exited (0) About an hour ago boring_shtern
c28ebaec5aeb hello-world "/hello" About an hour ago Exited (0) About an hour ago crazy_wiles
b1ff5faed1ca scrapinghub/splash "python3 /app/bin/sp…" 21 hours ago Exited (0) 17 hours ago amazing_zhukovsky
$ docker exec -it c4c6b6545289 bash
Error response from daemon: Container c4c6b6545289d8b5cc2d6349eaa9ab39ca407ba811fb1116da41d9640a16c41b is not running
$ docker restart c4c6b6545289
c4c6b6545289
$ docker exec -it c4c6b6545289 bash
さきほど作ったサンプルファイルは消えずに残っていることが確認できます。
root@c4c6b6545289:/# ls
a_sample.txt bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@c4c6b6545289:/# cat a_sample.txt
This is a sample text
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fcc850c3e81a 831691599b88 "bash" 40 minutes ago Exited (130) 19 minutes ago condescending_banzai
c4c6b6545289 ubuntu "bash" About an hour ago Up 4 minutes eloquent_bohr
1b0497e57c41 scrapinghub/splash "python3 /app/bin/sp…" About an hour ago Exited (0) About an hour ago boring_shtern
c28ebaec5aeb hello-world "/hello" About an hour ago Exited (0) About an hour ago crazy_wiles
b1ff5faed1ca scrapinghub/splash "python3 /app/bin/sp…" 21 hours ago Exited (0) 17 hours ago amazing_zhukovsky
$ docker commit c4c6b6545289 ubuntu:test_update
sha256:a08a259e2ad0c475670dd1535e8d8a49188d1b994e12752aae284103ee30cc8b
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu test_update a08a259e2ad0 8 seconds ago 73.9MB
ubuntu latest 74435f89ab78 3 days ago 73.9MB
scrapinghub/splash latest 4ddd2efcb0df 5 months ago 2.17GB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
更新されたイメージをプッシュするためにタグ付けを行っておきます。
$ docker tag ubuntu:test_update <repo_name>/test-repo
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu test_update a08a259e2ad0 8 minutes ago 73.9MB
<repo_name>/test-repo latest a08a259e2ad0 8 minutes ago 73.9MB
ubuntu latest 74435f89ab78 3 days ago 73.9MB
scrapinghub/splash latest 4ddd2efcb0df 5 months ago 2.17GB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
タグ付けしたイメージをプッシュするには、リポジトリが必要です。このリポジトリをDocker Hubに作っておきます。Docker Hubの「Create a Repository」を押して、
$ docker pull <repo_name>/test-repo:latest
latest: Pulling from <repo_name>/test-repo
Digest: sha256:494ca8c9c87c8304caf60cf11341d0d4969e04248671114d3806494ec8bce9a8
Status: Downloaded newer image for <repo_name>/test-repo:latest
docker.io/<repo_name>/test-repo:latest
~ took 3s
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<repo_name>/test-repo latest a08a259e2ad0 28 minutes ago 73.9MB
ubuntu test_update a08a259e2ad0 28 minutes ago 73.9MB
ubuntu latest 74435f89ab78 3 days ago 73.9MB
scrapinghub/splash latest 4ddd2efcb0df 5 months ago 2.17GB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
$ docker run -it <repo_name>/test-repo bash
root@4ef71bdfe48a:/# cat a_sample.txt
This is a sample text