Docker 启动 Nginx
Docker 启动 Nginx
启动容器
# 映射 9003 端口
# 映射当前目录下的 html 目录
docker run -d \
--name nginx-test \
-p 9003:80 \
nginx:1.17.9
访问
http://ip:9003/
进入容器
docker exec -it nginx-test /bin/bash
将配置文件拷贝到宿主机
docker cp nginx-test:/etc/nginx/conf.d/default.conf ./
修改配置文件
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
将配置文件放入容器
docker cp ./default.conf nginx-test:/etc/nginx/conf.d/default.conf
docker restart nginx-test