1、dockerfile
FROM nginx AS base
WORKDIR /app
EXPOSE 80
COPY . /app
2、dockercompose.yaml
version: '3'
services:
adminservice:
container_name: adminweb
build:
context: ./
dockerfile: Dockerfile
ports:
- "5000:80"
labels:
description: 'adminweb'
restart: always
3、运行dockercompose.yaml后,找到nginx配置文件/etc/nginx/nginx.conf
4、在access_log 后面增加配置
server
{
listen 80; #监听的端口
server_name localhost; #server_name 以localhost访问,server_name 写成127.0.0.1则需要以127.0.0.1访问(宝塔网站配置要以ip,自行在配置文件中修改成localhost则以名称访问)
index index.html index.htm default.htm default.html;
root /app; #网站根目录
}
5、以http://localhost:5000访问docker中部署的网站