基本概念
首先,获取图像
docker image pull nginx
确认能够获取到图像
[root@centos8_1 ~]# docker image list
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/nginx latest eea7b3dcba7e 11 days ago 191 MB
通过镜像启动容器。
对于首次启动的 nginx
docker run --name nginx11 -d -p 8080:80 nginx
确认启动成功
docker ps -a
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26c521619cb3 docker.io/library/nginx:latest nginx -g daemon o... 18 seconds ago Up 18 seconds ago 0.0.0.0:8080->80/tcp nginx11
为展示酷炫的一面而执行top命令。
[root@centos8_1 ~]# docker top nginx11
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
USER PID PPID %CPU ELAPSED TTY TIME COMMAND
root 1 0 0.000 40.117936328s ? 0s nginx: master process nginx -g daemon off;
nginx 28 1 0.000 40.118034197s ? 0s nginx: worker process
nginx 29 1 0.000 40.118061315s ? 0s nginx: worker process
停止容器
docker stop nginx11
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
nginx11
##停止したことを確認
[root@centos8_1 ~]# docker ps
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
启动容器
[root@centos8_1 ~]# docker start nginx11
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
nginx11
[root@centos8_1 ~]#
##起動したことを確認
[root@centos8_1 ~]# docker ps
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26c521619cb3 docker.io/library/nginx:latest nginx -g daemon o... 5 minutes ago Up 2 seconds ago 0.0.0.0:8080->80/tcp nginx11