3

I have Ubuntu 20.04, Mozilla Firefox 87.0, Google Chrome 89.0.4389.90.

I am trying to run the Docker Getting-started tutorial. I read a couple of posts from stack overflow to not avail. Also I checked this ToDo App (localhost:3000) shows no UI in Browser #9 and this enter link description here again to not avail. I do,

sudo docker build -t getting-started . sudo docker run -dp 3000:3000 getting-started

and then when I go to http://localhost:3000 I get,

In Firefox, enter image description here

in Chrome the following images alternate, enter image description here enter image description here

When I run, sudo docker ps -a I get, enter image description here

Finally, do you suggest any Docker tutorial for beginners? I want to have enough understanding for Docker so that I can write scripts to manage docker images.

3
  • 1
    try -p3000:80 instead of -p3000:3000
    – NobbyNobbs
    Mar 26, 2021 at 17:26
  • 1
    I tried it but instead of showing the app, it shows the local tutorial page.
    – vpap
    Mar 26, 2021 at 18:22
  • Are all of the geting-started containers on the same port?
    – Tony
    Nov 16, 2021 at 9:46

4 Answers 4

7

You might be building and running the Dockerfile outside the "app" directory which has this behaviour. As the tutorial says, first go to the app directory, create a Dockerfile there and then build and run. This should work.

3000:80 opens the tutorial because the default Dockerfile builds the docker/getting-started which is the tutorial.

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 10, 2021 at 19:11
  • I had to put 4000:3000 in the first lesson. I could see that when I omitted -d in the call. It then told me it was listening to port 3000.
    – larand
    Nov 10, 2021 at 17:55
3

Might be the problem something is blocking the port on your machine so try to Replace the port to 80 instead of 3000. Change from

docker run -dp 3000:3000 getting-started

to

docker run -dp 3000:80 getting-started

and then open browser and hit http://localhost:3000

1

Answer 1 is correct but I would like to give a little explanation as to why you have to change "3000:3000" to "3000:80".

The port number before the colon represents the outgoing port and the port number after the colon represents the internal port inside the docker container.

1

"As the tutorial says, first go to the app directory, create a Dockerfile there and then build and run."

This solves the problem. If you build and run from the root - there is existing Dockerfile in there, it want work. Go to app folder, create Dockerfile with the content from the tutorial, build and run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.