網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
使用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)建并啟動(dò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
本地瀏覽器可以訪問(wèn),說(shuō)明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
后臺(tái)up
(防火墻需要先開(kāi)啟,不然會(huì)報(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
啟動(dòng)服務(wù):
[root@192 ~]# docker compose start nginx [+] Running 1/1 ? Container nginx Started
原文鏈接:https://blog.csdn.net/qq_37960603/article/details/122907139
相關(guān)推薦
- 2022-06-04 Android基于Fresco實(shí)現(xiàn)圓角和圓形圖片_Android
- 2022-05-17 qt 解決Error while building/deploying project Hmi (k
- 2022-05-25 詳解C++類的成員函數(shù)做友元產(chǎn)生的循環(huán)依賴問(wèn)題_C 語(yǔ)言
- 2023-12-20 UML類圖中各箭頭表示總結(jié)
- 2023-07-28 el-tabs 切換之前判斷是否滿足條件,不滿足則提示用戶,不能切換
- 2022-12-04 React條件渲染實(shí)例講解使用_React
- 2022-05-31 postman批量執(zhí)行接口測(cè)試的圖文步驟_其它綜合
- 2023-05-20 Android內(nèi)存泄漏導(dǎo)致原因深入探究_Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支