docker run -itd -p 8080:80 -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf --name=webtest nginx:latest
命令创建容器,将宿主机nginx.conf文件映射到容器内部nginx服务/etc/nginx/目录下
步骤二:当我们修改容器内的nginx.conf配置文件时,直接修改宿主机/etc/nginx/nginx.conf配置即可,如图,我们在宿主机插入hello数据,进入容器内部检查,容器内数据也会发生变化
方法三: 修改dockerfile
docker镜像没有vim,下载也比较麻烦,可以使用
docker cp docker镜像名:想要修改的文件的路径 想要复制到的路径
将镜像中的文件复制到镜像外部,然后使用系统的vim修改,修改后再把文件复制回去。
docker cp zookeeper-server:/etc ~/tmp
注意:修改完cp回镜像的时候可能会失败,原因可能是该文件正在被使用
可以先把该docker镜像服务停止,再把文件cp回去,重启docker镜像的服务后新的文件就发挥作用了~
https://blog.csdn.net/qq_40741855/article/details/106495679?spm=1001.2014.3001.5501
https://blog.csdn.net/weixin_42867492/article/details/107870650