% 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
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.