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

时间:2016-07-15 11:15:16

标签: apache docker server openerp

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

1 个答案:

答案 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