//启动容器 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
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
docker-compose up -d
ip:11080/index.html