从Docker容器中复制文件到宿主机中
- 使用命令
docker cp <容器id>:/etc/nginx.conf /root/
复制容器的conf文件到root目录 docker logs <容器id>
查看docker容器的日志- 将docker已经运行的容器端口映射到宿主机端口,在宿主机使用如下命令
iptables -t nat -A DOCKER -p tcp --dport <宿主机端口> -j DNAT --to-destination <容器IP>:<容器端口>
iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp --source <容器IP> --destination <容器IP> --dport <宿主机端口>
iptables -A DOCKER -j ACCEPT -p tcp --destination <容器IP> --dport <宿主机端口>