% docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: <ユーザ名>
Password:<パスワード>
Login Succeeded
Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/
% docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
4.CentOSイメージが取得できたか確認する
「docker image」コマンドを使い、CentOSのイメージが取得できたか確認します。
% docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 12766a6745ee 3 months ago 142MB
centos latest 5d0da3dc9764 9 months ago 231MB
5.CentOSを起動する
「docker run 」コマンドを使い、CentOS を起動します。 なおこのときに-it -d –nameを引数として使っていますが、以下の意味らしいです。
-it : i は –interactive、tはttyを指している -d :detouchの意味でバックグラウンドでコンテナを起動する -name:この後に起動する「コンテナ名」と「コンテナイメージ」を指定する
また起動したかどうかは「docker ps」コマンドで確認できます。
以下、実行例です。
% docker run -it -d --name centos centos
e6adb5a6a86d3c2682f64e064ba4d7e93624d493c48575c12305ae9e09319654
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e6adb5a6a86d centos "/bin/bash" 7 seconds ago Up 6 seconds centos
1bee05eeb204 centos:latest "/bin/bash" 3 minutes ago Up 3 minutes condescending_banach