Docker port mapping is not working

Hi ,

I am trying to finish a LAB from Docker for Absolute beginners.
Under Section Docker run when I try to run command for this question:

Question:
Run an instance of kodekloud/simple-webapp with a tag blue and map port 8080 on the container to 38282 on the host.

Command ran:
docker run -p 38282:8080 kodecloud/simple-webapp:blue

Getting below error:
Unable to find image ‘kodecloud/simple-webapp:blue’ locally
docker: Error response from daemon: pull access denied for kodecloud/simple-webapp, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied.
See ‘docker run --help’.

Can someone advise what is the issue here.

I have checked the lab and could see the container is up… It may be a temporary issue with the lab…

Please retry and let us know the issue persists…

It works fine now kindly check.

Hello @Ayman

I am checking this lab and in this labs it seems to docker is able to pull the image and still runs into an error and not able to run the container .Below is the error message .

Can you please review below and advise ?

Error on 1st attempt :

docker: Error response from daemon: driver failed programming external connectivity on endpoint condescending_montalcini (d3a59b7c5495c359f008ef7ae14b3709012166fd6afb5f1a39fd9ed17471fd65): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.

2nd attempt :
docker: Error response from daemon: driver failed programming external connectivity on endpoint clever_darwin (c16ef282cc93915f10b6fa63980a08d203e7a29dfc30b0a63f1356790ef5983f): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
ERRO[0000] error waiting for container: context canceled



$ 
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                           NAMES
0a9da537202f        nginx:alpine        "/docker-entrypoint.…"   3 seconds ago       Up 2 seconds        0.0.0.0:3456->3456/tcp, 0.0.0.0:38080->80/tcp   stoic_bohr
$ 
$ 
$ docker run -p 8080:38282 -d kodekloud/simple-webapp:blue
Unable to find image 'kodekloud/simple-webapp:blue' locally
blue: Pulling from kodekloud/simple-webapp
4fe2ade4980c: Pull complete 
7cf6a1d62200: Pull complete 
f0d690b9e495: Pull complete 
fac5d45ad062: Pull complete 
a6fc8a0deb7d: Pull complete 
f43c8e496f88: Pull complete 
58ca939f7651: Pull complete 
095a1a007cdb: Pull complete 
Digest: sha256:9caf15476dc60b77c7460791bea8ea5f6ca02b90199aabe088beea83bc943fe5
Status: Downloaded newer image for kodekloud/simple-webapp:blue
5d59bdbbe0fbb43cc0a766b6ec10381fa00dd98eeab19ea260c8745063440dea
docker: Error response from daemon: driver failed programming external connectivity on endpoint condescending_montalcini (d3a59b7c5495c359f008ef7ae14b3709012166fd6afb5f1a39fd9ed17471fd65): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
$ 
$ docker run -p 8080:38282 kodekloud/simple-webapp:blue
docker: Error response from daemon: driver failed programming external connectivity on endpoint clever_darwin (c16ef282cc93915f10b6fa63980a08d203e7a29dfc30b0a63f1356790ef5983f): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
ERRO[0000] error waiting for container: context canceled 
$ 
$ pwd
/root
$ date
Mon  1 Feb 15:26:18 UTC 2021
$ 
$ history
   1  while [ ! -f /tmp/wait-script.sh ]; do   sleep .2; done
   2  chmod 755 /tmp/wait-script.sh; /tmp/wait-script.sh
   3  docker ps
   4  docker run -p 8080:38282 -d kodekloud/simple-webapp:blue
   5  docker run -p 8080:38282 kodekloud/simple-webapp:blue
   6  pwd
   7  date
   8  history
$ 


Hello, @ppnehe
As I can see, port 8080 is already in use. You can check by netstat -ntalp | grep 8080 command. Because it is already in use, you can’t assign to other processes.
8080 - host system port
38282 - docker container port
If you wanna port mapping to container port 8080 to host system port 38282 then
docker run -p 38282:8080 -d kodekloud/simple-webapp:blue
Hope it helps you.

Regards,

1 Like

sample examples are available in the below link:

its kodekloud not kodecloud. :stuck_out_tongue_winking_eye:

you need to type -p 32828:8080, not 8080:32828

1 Like