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資料卷