Debian 9 Stretch に Docker をインストールして動作確認を行うまで。
$ sudo apt update
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
/etc/apt/sources.list に次の一行を追加する。
deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable
もう一度 apt update して更新を行ったあとにインストールを行います。
$ sudo apt update
$ sudo apt install docker-ce
動作確認に hello-world の image を run してみます。
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
The Docker client contacted the Docker daemon.
The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
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/
ローカルのイメージを表示
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 4ab4c602aa5e 2 months ago 1.84kB
動作中のコンテナを表示
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
全てのコンテナを表示
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d4807dccc3c hello-world "/hello" 8 minutes ago Exited (0) 8 minutes ago friendly_chandrasekhar
コンテナの削除
CONTAINER ID を指定します。
$ sudo docker rm 4d4807dccc3c
4d4807dccc3c
ローカルのイメージを削除
イメージの名前か IMAGE ID を指定します。
$ sudo docker rmi hello-world
$ sudo docker rmi 4ab4c602aa5e