Home > OS >  Docker doesn't map to a different port?
Docker doesn't map to a different port?

Time:04-11

If I understand the command docker run correctly, docker run -p 3000:3000 someimage publishes port 3000 in the container to port 3000 on localhost. I'm testing this with the 'getting-started' node app, and it works as expected.

But I thought that docker run -p 3000:3001 someimage would publish what's on port 3000 inside the docker contain to localhost:3001, but instead of seeing the application, the browser shows:

This site can’t be reached

This seems pretty straight forward, what am I doing wrong here?

CodePudding user response:

The first number is the outside port. To map conatiner port 3000 to host port 3001, use -p 3001:3000

  • Related