docker部署Nginx


 

(核心:端口暴露)

 

1,搜索Nginx鏡像

docker search nginx

 

2,下載鏡像

docker pull nginx

 

3,運行容器,起名為nginx01 ,通過本機的3344端口號可以訪問到容器的80端口你

docker run -d --name nginx01 -p 3344:80 nginx

 

端口暴露的概念:

 

 

 

 

4,先本機測試以下

 

[root@CentOs /]# curl localhost:3344
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@CentOs /]#

 

或者:

 

 

 

 

5,進入nginx

 

[root@CentOs /]# docker exec -it nginx01 /bin/bash
root@b6e940ca5783:/#

進入后可以找一下nginx的配置文件

root@b6e940ca5783:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@b6e940ca5783:/# cd /etc/nginx/
root@b6e940ca5783:/etc/nginx# ls
conf.d    fastcgi_params    mime.types  modules  nginx.conf  scgi_params  uwsgi_params
root@b6e940ca5783:/etc/nginx#

 

思考:

我們每次改動nginx配置文件,都要進入容器內部,十分的麻煩,要是可以在容器外部提供一個映射路徑,

達到在容器修改文件名,容器內部也就可以自動修改了? -v數據卷

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM