Docker 實戰系列 Web與Nginx

2021-09-29 01:25:22 字數 2375 閱讀 3606

不適用html,只是hello word

docker run -p 80:80 --name xm-nginx -d nginx:1.15.11-alpine
如果你不需要https,直接忽略https配置即可,這裡只是簡單說明

假如我的網域名稱是這裡只是說明,這兩個網域名稱二級網域名稱並不存在

首先為https網域名稱申請 免費證書

docker run --rm  -it  \

-v "$(

pwd)

/out":/acme.sh \

--net=host \

演示目錄情況

.

├── nginx.conf

│ └── index.html

├── conf.d

│ └── default.conf

├── ssl

│ ├── fullchain.cer

└── web

└── index.html

# web 專案2

具體檔案內容

}執行

請刪除下面注釋後,執行

docker run -p 80:80 -p 443:443 \

# 容器名

--name xm-nginx \

# 配置檔案

-v $pwd/nginx.conf:/etc/nginx/nginx.conf \

-v $pwd/conf.d:/etc/nginx/conf.d \

# https配置,沒有可以回了

-v $pwd/ssl:/etc/nginx/ssl \

# html 配置

-v $pwd/web:/usr/share/nginx/web \

# 日誌

-v $pwd/logs:/var/logs \

# 執行容器版本

-d nginx:1.15.11-alpine

docker run -p 80:80

-p 443

:443 \

--name xm-nginx \

-v $pwd/nginx.conf:

/etc/nginx/nginx.conf \

-v $pwd/conf.d:

/etc/nginx/conf.d \

-v $pwd/ssl:

/etc/nginx/ssl \

-v $pwd/web:

/usr/share/nginx/web \

-v $pwd/logs:

/var/logs \

-d nginx:

1.15

.11-alpine

檢視啟動是否成功

docker ps
失敗檢查

docker logs -f xm-nginx
訪問網頁

html檔案更新後,重新nginx

vim web/index.html

hello, docker! version:

2.0<

/h1>

docker exec

-it xm-nginx nginx -s reload

Docker詳解與實戰

依賴安裝方式 wget 2 安裝docker rpm ivh docker ce 17.12.0.ce 1.el7.centos.x86 64.rpm 3 啟動docker systemctl start docker 4 開機啟動docker systemctl enable docker 映象是...

Docker 介紹與實戰

解決如下問題 docker的架構介紹和基本使用 守護程序負責來與映象,倉庫和容器進行交流 docker的一些常用方法 1.執行daocloud.io nginx,由80埠對映在本地8080埠上 docker run p 8080 80 d daocloud.io nginx p 做埠對映,d 允許這...

Docker系列之實戰 6 安裝Redis

root centos181001 cat etc centos release centos linux release 7.6.1810 core root centos181001 docker v docker version 18.09.1,build 4c52b90 搜尋映象 docke...