Reputation: 831
I created a Asp.net application with Docker (windows) support. I created image (eshoplegacymvc:dev) of it and run it using command
docker run eshoplegacymvc:dev
I ran above command multiple times, what I understand is that when we run it, website will be available.
Queries :
1) So if I run it 5 times, does it mean 5 instance of those websites are running?
2) If yes, then why port number of all is same? And how can I access those websites from local machine, I am not able to do that.
See below screenshot which shows all process running by using docker command
Docker ps
Upvotes: 0
Views: 1152
Reputation: 30160
docker run -p 8888:80 eshoplegacymvc:dev
using this command you can map ports
your website will be running on localhost:8888
for 5 container you can do it 5 time with -p 8777:80 with different ports 8888:80 ; 8999:80 which addressing to container port 80 and exposing it over 8777
Upvotes: 1
Reputation: 674
While running the docker command, you have not specified the port mapping. The ports 80/tcp shown is of container tcp port and not host port.
1) Yes, you are running 5 instance of websites. 2) To access website, you need to provide different port mapping for each container instance.
Example:
docker run -p 8081:80 eshoplegacymvc:dev
docker run -p 8082:80 eshoplegacymvc:dev
docker run -p 8083:80 eshoplegacymvc:dev
docker run -p 8084:80 eshoplegacymvc:dev
docker run -p 8085:80 eshoplegacymvc:dev
In the above examples, tcp port 80 of the container binds to TCP port 8081/8082/8083/8084/8085 of the host machine.
You can access the site using http://localhost:8081/
For more information on port binding you can check docker docs
Upvotes: 2