3pepe3
3pepe3

Reputation: 613

Run multiple Docker container on same port with different URLs

In docker ss there a way to run multiple containers on same port but with different public URL? Lets say instead of x.x.x.x:8090 use something like: site

something like this:

docker run --name test1 -e VIRTUAL_HOST=site1.example.com -p 8090:80 -e AUTHOR="test1" -d -P dockersamples/static-site
docker run --name test2 -e VIRTUAL_HOST=site2.example.com -p 8090:80 -e AUTHOR="test2" -d -P dockersamples/static-site

Upvotes: 0

Views: 1445

Answers (1)

ldg
ldg

Reputation: 9402

You would typically use a proxy like nginx to accomplish this where the proxy runs in a container on the same network as your other containers. You can then use the Docker service name for the proxy backend source.

Upvotes: 2

Related Questions