使用docker部署Nginx服务器


1.创建Dockerfile

[root@LIN-52E5F1B482B Desktop]# mkdir Dockerfile [root@LIN-52E5F1B482B Desktop]# cd Dockerfile/

2.编辑Dockerfile

[root@LIN-52E5F1B482B Dockerfile]# vi Dockerfile
FROM nginx RUN echo "hello nginx" > /usr/share/nginx/html/index.html

3.创建镜像

[root@LIN-52E5F1B482B Dockerfile]# docker build -t nginx:v1 .

4.创建容器

docker run -it --name mynginx -p 9999:80 nginx:v1

5.进入容器

[root@LIN-52E5F1B482B Dockerfile]# docker start c414fbeb39aa
c414fbeb39aa
[root@LIN-52E5F1B482B Dockerfile]# docker exec -it c414fbeb39aa /bin/bash 

6.查看index.html

root@c414fbeb39aa:/# cat /usr/share/nginx/html/index.html
hello nginx

访问路径:http://127.0.0.1:9999


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM