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