我已经下载了Odoo容器,我想在我的服务器内运行它并从外部获取访问权限。这意味着我想在localhost:8069中运行容器并从以下位置获取访问权限:8000(8000是一个开放端口,apache2从中提供服务)。这可能吗?
答案 0 :(得分:0)
要允许从外部访问Dockerized服务,您可以使用命令--publish
的选项docker run
从手册页:
-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. (e.g., 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
。