docker安装运行nginx
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE      COMMAND       CREATED        STATUS        PORTS     NAMES
e40e729d2da2   centos:7   "/bin/bash"   18 hours ago   Up 18 hours             c7
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE      COMMAND       CREATED        STATUS                    PORTS     NAMES
e40e729d2da2   centos:7   "/bin/bash"   18 hours ago   Up 18 hours                         c7
1f2abcd6ae16   centos:7   "/bin/bash"   18 hours ago   Exited (0) 18 hours ago             priceless_davinci
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
Digest: sha256:029d4461bd98f124e531380505ceea2072418fdf28752aa73b7b273ba3048903
Status: Image is up to date for nginx:latest
docker.io/library/nginx:latest
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE      COMMAND       CREATED        STATUS        PORTS     NAMES
e40e729d2da2   centos:7   "/bin/bash"   18 hours ago   Up 18 hours             c7
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker run --name c1 -it -d  nginx:latest /bin/bash
a2e58a56047d4fdde5a40d1d67aefb6eee98b6153696b0178e501ba0d5f99853
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
a2e58a56047d   nginx:latest   "/docker-entrypoint.…"   6 seconds ago   Up 6 seconds   80/tcp    c1
e40e729d2da2   centos:7       "/bin/bash"              18 hours ago    Up 18 hours              c7
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker exec -it a2e58a56047d /bin/bash
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/# ps aux
bash: ps: command not found
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/# ps
bash: ps: command not found
root@a2e58a56047d:/# top
bash: top: command not found
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/# ping
bash: ping: command not found
root@a2e58a56047d:/#
root@a2e58a56047d:/#
root@a2e58a56047d:/# cd /etc/nginx/
root@a2e58a56047d:/etc/nginx#
root@a2e58a56047d:/etc/nginx#
root@a2e58a56047d:/etc/nginx# ls
conf.d	fastcgi_params	mime.types  modules  nginx.conf  scgi_params  uwsgi_params
root@a2e58a56047d:/etc/nginx#
root@a2e58a56047d:/etc/nginx# ll
bash: ll: command not found
root@a2e58a56047d:/etc/nginx#

在已经运行的容器里的/tmp目录下创建一个空文件luffy.txt但是不允许进入到容器里
保持容器不能退出
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS     NAMES
a2e58a56047d   nginx:latest   "/docker-entrypoint.…"   11 minutes ago   Up 11 minutes   80/tcp    c1
e40e729d2da2   centos:7       "/bin/bash"              18 hours ago     Up 18 hours               c7
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ll /tmp/
total 1056
-rw-r--r--. 1 root root   1148 Aug 26 12:36 anaconda.log
drwxr-xr-x. 2 root root     18 Aug 26 12:30 hsperfdata_root
-rw-r--r--. 1 root root    415 Aug 26 12:36 ifcfg.log
-rwx------. 1 root root    836 Aug 26 12:35 ks-script-UBBv65
-rw-r--r--. 1 root root      0 Aug 26 12:36 packaging.log
-rw-r--r--. 1 root root      0 Aug 26 12:36 program.log
-rw-r--r--. 1 root root      0 Aug 26 12:36 sensitive-info.log
drwx------. 2 root root     25 Aug 26 15:09 ssh-rA2eJ6KFQ8AD
-rw-r--r--. 1 root root      0 Aug 26 12:36 storage.log
drwx------. 3 root root     17 Aug 26 12:36 systemd-private-27fa29fb018048e4b15c2cdf4992cb29-bolt.service-1qdJFl
drwx------. 3 root root     17 Aug 26 12:36 systemd-private-27fa29fb018048e4b15c2cdf4992cb29-colord.service-331CiN
drwx------. 3 root root     17 Aug 26 12:36 systemd-private-27fa29fb018048e4b15c2cdf4992cb29-cups.service-c1ZQNL
drwx------. 3 root root     17 Aug 26 15:09 systemd-private-27fa29fb018048e4b15c2cdf4992cb29-fwupd.service-JrsGcH
drwx------. 3 root root     17 Aug 26 12:36 systemd-private-27fa29fb018048e4b15c2cdf4992cb29-rtkit-daemon.service-pLS1La
drwx------. 2 root root      6 Oct 10 10:57 tracker-extract-files.0
drwx------. 2 root root      6 Aug 26 12:36 vmware-root_6213-1723601999
-rw-------. 1 root root      0 Aug 26 12:29 yum.log
-rw-------. 1 root root   2870 Oct 10 10:11 yum_save_tx.2025-10-10.10-11.M6Eym7.yumtx
-rw-------. 1 root root 528409 Oct 24 11:16 yum_save_tx.2025-10-24.11-16.VTc0jh.yumtx
-rw-------. 1 root root 528409 Oct 25 15:23 yum_save_tx.2025-10-25.15-23.t3yigm.yumtx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker exec e40e729d2da2 ls /tmp/luffy.txt
/tmp/luffy.txt
[root@localhost ~]#
[root@localhost ~]#

