Docker Community Forums

Share and learn in the Docker community.

How to assign a reserved IP address to docker container in windows


(Singhasit2012) #1

Hi ,
I am creating a docker on windows for my web application and I have done with this part but whenever my system get shut down it changes the Ip for that container .so how to run container forcefully on same IP

  • :whale: :arrow_right:️ Settings :arrow_right:️ Diagnose & Feedback :arrow_right:️ Open Issues.

This forum is not an official product support or issue reporting channel.


(David Maze) #2

Usually, you don’t. You use the docker run -p option to assign a port on the host system for your service, and external callers use the host system’s DNS name and the port you assigned with -p. The container’s private internal IP address is completely irrelevant for almost every application.


(Singhasit2012) #3

Thanks David ,
Its really helpful I have one more question I am creating a web site and a web service into docker and both run on port 80 how to create two container with 80 port ? I am trying to do but it is not being created .

Thanks!


(David Maze) #4

[quote=“singhasit2012, post:3, topic:39232, full:true”]
Its really helpful I have one more question I am creating a web site and a web service into docker and both run on port 80 how to create two container with 80 port ? I am trying to do but it is not being [/quote]

The host only has one port 80. You could run a reverse proxy in front of both of them and publish the reverse proxy as port 80; or you could pick different ports

docker run -p 8000:80 httpd
docker run -p 8001:80 httpd

Then port 8000 on the host would reach port 80 of the first container, and port 8001 would reach port 80 of the second container.