[admin@RockyLinux9 ~]$ sudo docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:c41088499908a59aae84b0a49c70e86f4731e588a737f1637e73c8c09d995654
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:
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:
[admin@RockyLinux9 ~]$ docker login
USING WEB-BASED LOGIN
i Info → To sign in with credentials on the command line, use 'docker login -u <username>'
Your one-time device confirmation code is: XXXX-XXXX ※⇩の行にアクセスするとコードの入力が求められるので投入。
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate
Waiting for authentication in the browser…
WARNING! Your credentials are stored unencrypted in '/home/admin/.docker/config.json'.
Configure a credential helper to remove this warning. See
[root@RockyLinux9 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 602eb6fb314b 3 weeks ago 78.1MB
hello-world latest 74cc54e27dc4 3 months ago 10.1kB
[root@RockyLinux9 ~]# docker run -i -t -d --name test -p 127.0.0.1:10080:80 ubuntu:latest
a4c75887600502937dc475d4246a735b609d84dc765f353b7892368228499cc4
全てのコンテナーの確認
起動の有無に関わらず全てのコンテナーを確認するには次のコマンドを使用します。
docker ps -a
出力例
[root@RockyLinux9 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4c758876005 ubuntu:latest "/bin/bash" 2 minutes ago Up 2 minutes 127.0.0.1:10080->80/tcp test
起動しているコンテナーの確認
起動しているコンテナーのみ確認するには次のコマンドを使用します。
docker ps
出力例
[root@RockyLinux9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4c758876005 ubuntu:latest "/bin/bash" 2 minutes ago Up 2 minutes 127.0.0.1:10080->80/tcp test
[root@RockyLinux9 ~]# docker rm a4c758876005
Error response from daemon: cannot remove container "/test": container is running: stop the container before removing or force remove
コンテナーの停止、停止後の削除まで行ってみたいと思います。
docker stop コンテナID
docker rm コンテナID
出力例
[root@RockyLinux9 ~]# docker stop a4c758876005
a4c758876005
[root@RockyLinux9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@RockyLinux9 ~]# docker rm a4c758876005
a4c758876005
[root@RockyLinux9 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@RockyLinux9 ~]#
コメント