繁体   English   中英

将Docker容器端口连接到服务器的apache端口(odoo容器)

[英]Connect Docker Container port to server's apache port (odoo Container)

我已经下载了Odoo容器,我想在服务器内部运行docker并从外部获取访问权限。 这意味着我想在localhost:8069中运行容器,并从:8000获得访问权限(8000是一个开放端口,而apache2从中提供服务)。 这可能吗?

要允许从外部访问Dockerized服务,可以使用--publish docker run命令的--publish选项

从手册页:

  -p, --publish=[] Publish a container's port, or range of ports, to the host. Format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort Both hostPort and containerPort can be specified as a range of ports. When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (eg, docker run -p 1234-1236:1222-1224 --name thisWorks -t busybox but not docker run -p 1230-1236:1230-1240 --name RangeContainerPortsBiggerThanRangeHostPorts -t busybox) With ip: docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT --name CONTAINER -t someimage Use docker port to see the actual mapping: docker port CONTAINER $CONTAINERPORT 

然后运行: docker run -p 1.2.3.4:8000:80 image-name会将服务器的套接字1.2.3.4:8000绑定到容器的端口80

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM