Docker error resolved - address already in use error

 The unfed mind devours itself. - Gore Vidal

 As I progress through my University of Oregon Cybersecurity part-time cybersecurity bootcamp, I've come to adore Linux machines. It is fun to take on the sys admin role. As part of one the class activities this week we had to get an instance of Docker running a Wordpress blog up and running. 

I encountered an error. When I find errors, I google them, and inevitably end up on stackoverflow.com.

The command I was running was:

 docker-compose up -d 

Brief reminder that docker-compose up -d, does the following (per documentation

Builds, (re)creates, starts, and attaches to containers for a service.

So while all my course mates were  building, creating, starting and attaching to containers for a wordpress service, I got an error. 

The docker-compose up  command triggered an error.

My error was: 


Starting docker_files_wordpress_1 ... 
docker_files_db_1 is up-to-date
Starting docker_files_wordpress_1 ... error

ERROR: for docker_files_wordpress_1  Cannot start service wordpress: driver failed programming 
external connectivity on
endpoint docker_files_wordpress_1 (1656f35cf3af623264b5a54180c0289e010ce7a2f9ac545ea09f3f5e3603b3c6):
Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use ERROR: for wordpress Cannot start service wordpress: driver failed programming external
connectivity on endpoint docker_files_wordpress_1
(1656f35cf3af623264b5a54180c0289e010ce7a2f9ac545ea09f3f5e3603b3c6):
Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use ERROR: Encountered errors while bringing up the project

The helpful, and therefore Googable bit was:

Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use
 

I opened the docker-compose.yml to look at the ports in use:

  ports:
      - 8080:80 

So I changed the port from 8080 to 8888:80. This enabled docker to get my Wordpress setup. That is the solution, change my port from one that was being used to something else. The docker setup could access port 8888 with no issue.

 The solution was easy to implement but there was a trial and error, Google to StackOverflow saga that I shall briefly note below. Each search yielded Linux commands to try to understand what was using the port, and how to fix it.

 This led to running docker-compose down command and examining what was running  on port 8080
by Googling until I got this command:

netstat -anp tcp | grep LISTEN

which yielded:

8080/tcp open  http-proxy

there are a variety of commands to examine ports on Linux. I was not too sure about how helpful this information was from Googling 8080/tc open http-proxy, so I used an additional command:

sysadmin@UbuntuDesktop:~$ sudo ss -tulwn | grep LISTEN 

that yielded more info: 

tcp    LISTEN   0        511                     *:8080                 *:* 

Feeling that 8080 was being used by something else, and needing to move forward on the activity, I googled myself to StackOverflow by googling the error bind: address already in use part and noticed there was someone the comments who mentioned using port 8888 for the docker proxy.

I tried that, and ran docker-compose up with success. So now I could run wordpress in a docker container and get on with the actual cybersecurity activity.

Google your error messages folks. And also try Twitter and YouTube. I got a lot of good info by searching the error on YouTube, and then a web developer who on 1/21/20 had the same error and tried to diagnose by using netstat to find which process is using that port and then task killing the PID. 

 

Comments