[英]Docker compose mapping port from container to localhost
I am trying to map the port of the db-container to my containers localhost:port. 我试图将db-container的端口映射到我的容器localhost:port。 Is there a way to map these ports?
有没有办法映射这些端口? (I want to reach the db inside wildfly on localhost at port 12345)
(我想在端口12345的localhost上的wildfly中访问数据库)
currently, my db is only under oracle:1521 reachable. 目前,我的数据库仅在oracle:1521下可访问。 but I want it to be reachable under localhost:12345.
但我希望它可以在localhost:12345下访问。
version: '3.5'
services:
wildfly:
image: wildfly:latest
ports:
- "32004:32004"
depends_on:
- oracle
links:
- oracle
oracle:
image: oracle-db:latest
expose:
- "1521"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:1521"]
interval: 2m
timeout: 10s
retries: 5
Thanks
谢谢
Sure, map exposed container port 1521 to host port 12345 with 确保将裸露的容器端口1521映射到主机端口12345
ports:
- "12345:1521"
for your oracle service like you do in the wildfly service. 像在wildfly服务中一样为您的oracle服务提供服务。 The pattern is
HOST_PORT:EXPOSED_CONTAINER_PORT
. 模式是
HOST_PORT:EXPOSED_CONTAINER_PORT
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.