JJMeliodax
JJMeliodax

Reputation: 31

Docker assign a public IP for single container

I installed docker to install over a container for each site I created only that to access port 80 I need each container to have its own public IP. How can I create a bridge network to correctly assign each container its public IP?

Currently I have seen that there is the subnet created by default by docker on class 172.17.0.0/16

Upvotes: 1

Views: 1054

Answers (1)

Antonio Petricca
Antonio Petricca

Reputation: 11006

You should create a bridged network as explaine in the official guide like follow:

docker network create my-net

docker create --name my-nginx \
  --network my-net \
  --publish 8080:80 \
  my-image

Or, if you prefer using docker compose, please refer to Docker compose networking guide.

Upvotes: 1

Related Questions