docker从images部署django项目

STEP1. image --> container

docker load < xxx.tar

docker run -dit --privileged <image id> /usr/sbin/init

STEP2. 开启端口映射

# 假设container内主机地址为172.16.0.3,我们要将ssh-server端口(22-->22222)和django-server端口(8000-->8088)映射出来

iptables -t nat -A DOCKER -p tcp --dport 22222 -j DNAT --to-destination 172.17.0.3:22

iptables -t nat -A DOCKER -p tcp --dport 8088 -j DNAT --to-destination 172.17.0.3:8000

iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp --source 172.17.0.3 --destination 172.17.0.3 --dport 22

iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp --source 172.17.0.3 --destination 172.17.0.3 --dport 8000

iptables -A DOCKER -j ACCEPT -p tcp --destination 172.17.0.3 --dport 22

iptables -A DOCKER -j ACCEPT -p tcp --destination 172.17.0.3 --dport 8000

STEP3. ssh连接container主机

# 先验证是否映射成功(假设外网ip是:x.x.x.x 端口是123)

windows系统:打开cmd窗口输入命令:telnet x.x.x.x 123

linux系统:输入命令:wget x.x.x.x:123

# 映射成功后登录主机上传项目文件

打开secureCRT连接上container主机后, 按alt + p进入sftp界面上传文件:put -r xxx

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容