Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in DevOps and Agile by (2.3k points)

how can I access docker container from outside?

1 Answer

0 votes
by (6.9k points)

Its simple, All you have to do is expose the container at the time of its creation like suppose you wanted to launch an nginx container and also wanted to be able to access it from outside you can do so in this way:

$ sudo docker run -d -p 9090:80 -t nginx

Now Nginx will be available at the port 80 of your localhost which is basically the default port.

so you can access it by going to your browser and typing this in the navigation bar:

localhost

If you get the nginx welcome message that means the task was successful. you can repeat this with the port & application of your choice ( eg. 8080 & tomcat )

Hope this helped :)


New to docker ? need help in understanding its concepts ? Looking for great customers? try out docker training course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...