微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐