一个docker容器暴露多个端口

how to configure multiple domain (virtual host) and multiple virtual port

# start the nginx proxy
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro \
    --name my-nginx-proxy --network=mynetwork jwilder/nginx-proxy

# start the application container, take note that:
# - it is named (so that the proxies below can see it)
# - it does not have anything exposed
docker run -d --network=mynetwork --name myapp application-with-two-ports

# For each port that you want to expose, configure a pseudo container. 
# These only forward to the 'myapp' container above.
# They are additionally labeled for 'nginx-proxy' to pick up on. 
docker run -d --network=mynetwork -e VIRTUAL_PORT=80 -e VIRTUAL_HOST=a.mydomain \
    -e REMOTE_HOST=myapp -e REMOTE_PORT=81 marcnuri/port-forward
docker run -d --network=mynetwork -e VIRTUAL_PORT=80 -e VIRTUAL_HOST=b.mydomain \
    -e REMOTE_HOST=myapp -e REMOTE_PORT=82 marcnuri/port-forward
posted @ 2024-06-03 08:25  shiningrise  阅读(26)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css