vim /usr/lib/sysctl.d/00-system.conf
添加如下内容:
net.ipv4.ip_forward=1
安装好docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
创建一个外部的容器挂载:
mkdir /root/nginx
先开启一个容器复制出/etc/nginx下的内容
随后删除之前起的容器执行以下命令:
docker run -p 9005:80 --name nginx -v /root/nginx/html:/usr/share/html -v /root/nginx/log:/var/log/nginx/ -v /root/nginx/conf:/etc/nginx/ -d nginx:1.10```
最终:
![在这里插入图片描述](https://www.icode9.com/i/ll/?i=6d7b5854c3314186a5b0250ca1eba778.png?,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAY29kaW5nIGlzIGludGVyZXN0aW4=,size_17,color_FFFFFF,t_70,g_se,x_16)