![](/img/trans.png)
[英]Apache redirect to different port for docker container ( Redmine )
[英]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.