Docker Compose部署Nginx的方法步驟
使用Docker Compose
部署Nginx
,創(chuàng)建docker-compose.yaml
:
[root@192 ~]# vim docker-compose.yaml
輸入以下內(nèi)容:
version: '3' services: nginx: container_name: nginx image: nginx restart: always ports: - 8080:80 privileged: true networks: - mynginx networks: mynginx: driver: bridge
基于docker-compose.yaml
創(chuàng)建并啟動容器:
[root@192 ~]# docker compose up [+] Running 7/7 ? nginx Pulled 20.5s ? 5eb5b503b376 Pull complete 12.6s ? 1ae07ab881bd Pull complete 14.8s ? 78091884b7be Pull complete 14.9s ? 091c283c6a66 Pull complete 15.0s ? 55de5851019b Pull complete 15.1s ? b559bad762be Pull complete 15.2s [+] Running 2/2 ? Network root_mynginx Created 0.3s ? Container nginx Created 1.8s Attaching to nginx nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh nginx | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf nginx | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh nginx | /docker-entrypoint.sh: Configuration complete; ready for start up nginx | 2022/02/13 03:43:39 [notice] 1#1: using the "epoll" event method nginx | 2022/02/13 03:43:39 [notice] 1#1: nginx/1.21.6 nginx | 2022/02/13 03:43:39 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) nginx | 2022/02/13 03:43:39 [notice] 1#1: OS: Linux 3.10.0-1160.el7.x86_64 nginx | 2022/02/13 03:43:39 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 nginx | 2022/02/13 03:43:39 [notice] 1#1: start worker processes nginx | 2022/02/13 03:43:39 [notice] 1#1: start worker process 31
關(guān)閉防火墻:
[root@192 ~]# systemctl stop firewalld
本地瀏覽器可以訪問,說明Nginx
部署成功了。
Docker
也可以查到Docker Compose
拉取的鏡像和創(chuàng)建的容器。
[root@192 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest c316d5a335a5 2 weeks ago 142MB lazyteam/lazydocker latest 3b572700e20d 10 months ago 69.9MB portainer/portainer latest 580c0e4e98b0 11 months ago 79.1MB openjdk 8-jdk-alpine a3562aa0b991 2 years ago 105MB [root@192 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e31945577104 nginx "/docker-entrypoint.…" 7 minutes ago Up 7 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp nginx
后臺up
(防火墻需要先開啟,不然會報(bào)錯(cuò)):
[root@192 ~]# systemctl start firewalld [root@192 ~]# docker compose up -d [+] Running 1/1 ? Container nginx Started
關(guān)閉服務(wù):
[root@192 ~]# docker compose stop nginx [+] Running 1/1 ? Container nginx Stopped
啟動服務(wù):
[root@192 ~]# docker compose start nginx [+] Running 1/1 ? Container nginx Started
到此這篇關(guān)于Docker Compose部署Nginx的方法步驟的文章就介紹到這了,更多相關(guān)Docker Compose部署Nginx內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Armbian5.9.0安裝docker及部署可視化portainer的詳細(xì)教程
這篇文章主要介紹了Armbian5.9.0安裝docker及部署可視化portainer的詳細(xì)教程,通過?ssh?進(jìn)去?Armbian?系統(tǒng)后,輸入相應(yīng)代碼,按提示輸入y,等待安裝完成即可,需要的朋友可以參考下2022-05-05IDEA連接遠(yuǎn)程服務(wù)器Docker部署Spring Boot項(xiàng)目的詳細(xì)教程
這篇文章主要介紹了IDEA連接遠(yuǎn)程服務(wù)器Docker部署Spring Boot項(xiàng)目,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06Docker容器Container鏡像Image如何存儲詳解
本文主要介紹Docker容器(Container)和鏡像(Image)是如何進(jìn)行數(shù)據(jù)存儲詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09Docker報(bào)錯(cuò):OCI?runtime?exec?failed:?exec?failed:?contain
這篇文章主要給大家介紹了關(guān)于Docker報(bào)錯(cuò):OCI?runtime?exec?failed:?exec?failed:?container_linux.go:380:?starting?container?process的解決方法,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07Docker Registry搭建私有鏡像倉庫的實(shí)現(xiàn)方法
這篇文章主要介紹了Docker Registry搭建私有鏡像倉庫的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10基于Docker+K8S+GitLab/SVN+Jenkins+Harbor搭建持續(xù)集成交付環(huán)境的詳細(xì)教程
K8S全稱是Kubernetes,是一個(gè)全新的基于容器技術(shù)的分布式架構(gòu)領(lǐng)先方案,這篇文章主要介紹了基于Docker+K8S+GitLab/SVN+Jenkins+Harbor搭建持續(xù)集成交付環(huán)境(環(huán)境搭建篇),對docker K8S持續(xù)集成交付環(huán)境相關(guān)知識感興趣的朋友一起看看吧2021-05-05docker操作Permission denied無權(quán)限的問題解決
我們?nèi)粘P枰猟ocker環(huán)境進(jìn)入容器配置或查看一些文件,本文主要介紹了docker操作Permission denied無權(quán)限的問題解決,具有一定的參考價(jià)值,感興趣的可以了解一下2024-06-06