系统相关
首页 > 系统相关> > docker-compose部署nginx-arm版本

docker-compose部署nginx-arm版本

作者:互联网

启动普通的nginx创建目录文件然后删除

//启动容器
docker run -p 10080:80 --name mynginx -d nginx
//进入容器
docker exec -it mynginx bash
//查看nginx目录
ls -al /etc/nginx
//退出容器复制mynginx容器中/etc/nginx下的文件到当前目录
exit
docker cp mynginx:/etc/nginx/nginx.conf .
docker cp mynginx:/etc/nginx/conf.d .
docker cp mynginx:/usr/share/nginx/html .
//删除容器
docker stop mynginx && docker rm mynginx

创建docker-compose文件

cat > docker-compose.yaml << EOF
version: '3'
services:
  nginx:
    container_name: nginx
    image: nginx
    restart: always
    ports:
      - 11080:80
    privileged: true
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./conf/nginx/log/:/var/log/nginx
      # 注意:如下挂载都是覆盖
      #- ./conf/nginx/conf.d:/etc/nginx/conf.d
      #- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      #- ./conf/nginx/html:/usr/share/nginx/html
EOF

在当前目录启动nginx

docker-compose up -d

访问测试

ip:11080/index.html

 

标签:容器,compose,etc,mynginx,nginx,docker
来源: https://www.cnblogs.com/cgy-home/p/16477693.html