[root@hspEdu01 nginx]# docker pull nginx Using default tag: latest Trying to pull repository docker.io/library/nginx ... latest: Pulling from docker.io/library/nginx 69692152171a: Already exists 30afc0b18f67: Pull complete 596b1d696923: Pull complete febe5bd23e98: Pull complete 8283eee92e2f: Pull complete 351ad75a6cfa: Pull complete Digest: sha256:6d75c99af15565a301e48297fa2d121e15d80ad526f8369c526324f0f7ccb750 Status: Downloaded newer image for docker.io/nginx:latest [root@hspEdu01 nginx]# ls conf logs www [root@hspEdu01 nginx]# cd conf/ [root@hspEdu01 conf]# ls nginx.conf [root@hspEdu01 conf]# cd ../ [root@hspEdu01 nginx]# cd ../ [root@hspEdu01 ~]# rm -rf nginx/ [root@hspEdu01 ~]# ls anaconda-ks.cfg data data2 initial-setup-ks.cfg mysql 公共 模板 视频 图片 文档 下载 音乐 桌面 [root@hspEdu01 ~]# docker run --name nginx-test -p 80:80 -d nginx 608ed67163e091695eb14f964cff6f4d24f2818275845f34254eff49e24fe770 [root@hspEdu01 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 608ed67163e0 nginx "/docker-entrypoin..." 4 seconds ago Up 2 seconds 0.0.0.0:80->80/tcp 760a2956258e a8e34 "java -jar app.jar" About an hour ago Up About an hour 0.0.0.0:8010->8010/tcp 95628d5d89c5 mysql:5.7 "docker-entrypoint..." About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp, 33060/tc [root@hspEdu01 ~]# mkdir -p /root/nginx/www /root/nginx/logs /root/nginx/conf [root@hspEdu01 ~]# cd nginx/ [root@hspEdu01 nginx]# cd conf/ [root@hspEdu01 conf]# ls [root@hspEdu01 conf]# docker cp 608e:/etc/nginx/nginx.conf /root/nginx/conf [root@hspEdu01 conf]# ls nginx.conf [root@hspEdu01 conf]# docker rm -f 608e 608e [root@hspEdu01 conf]# docker run -d -p 80:80 --name nginx-web -v /root/nginx/www:/usr/share/nginx/html -v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /root/nginx/logs:/var/log/nginx nginx 987bc07bc4eb474332766dfe6409d957e07bf94fc24153222cf8bf99147df717 [root@hspEdu01 conf]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 987bc07bc4eb nginx "/docker-entrypoin..." 10 seconds ago Exited (1) 9 seconds ago nginx-web 760a2956258e a8e34 "java -jar app.jar" About an hour ago Up About an hour 0.0.0.0:8010->8010/tcp adoring\_pare 95628d5d89c5 mysql:5.7 "docker-entrypoint..." About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp, 33060/tcp mysql [root@hspEdu01 conf]# docker logs -f 987b /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2021/06/12 02:26:39 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (13: Permission denied) [root@hspEdu01 conf]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 987bc07bc4eb nginx "/docker-entrypoin..." About a minute ago Exited (1) About a minute ago nginx-web 760a2956258e a8e34 "java -jar app.jar" About an hour ago Up About an hour 0.0.0.0:8010->8010/tcp adoring\_pare 95628d5d89c5 mysql:5.7 "docker-entrypoint..." About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp, 33060/tcp mysql [root@hspEdu01 conf]# docker rm -f 987 987 [root@hspEdu01 conf]# docker run -d -p 80:80 --name nginx-web -v /root/nginx/www:/usr/share/nginx/html -v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /root/nginx/logs:/var/log/nginx --privileged=true nginx 6593ed8866071e1865217f58c627005aa8f3e9b3c8db6f5ff1aec22653503d1a [root@hspEdu01 conf]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6593ed886607 nginx "/docker-entrypoin..." 5 seconds ago Up 3 seconds 0.0.0.0:80->80/tcp nginx-web 760a2956258e a8e34 "java -jar app.jar" About an hour ago Up About an hour 0.0.0.0:8010->8010/tcp adoring\_pare 95628d5d89c5 mysql:5.7 "docker-entrypoint..." About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp, 33060/tcp mysql [root@hspEdu01 conf]# cd ../ [root@hspEdu01 nginx]# cd www/ [root@hspEdu01 www]# touch a.html [root@hspEdu01 www]# vim a.html [root@hspEdu01 www]#