Docker Community Forums

Share and learn in the Docker community.

Binding existing container to port OR binding new container to port

raspberrypi

(Exodvs) #1

Recently, my lab partners and I have been trying to build a website hosted on our Raspberry Pi through Docker. A few days ago, we had a functioning website, and our container was port forwarded to port 80. However, I was not getting any PHP code to work, so I looked around, and one of the advice pages I read said to restart the container. So I did, and now the container is no longer port forwarded. I looked around again and saw no simple answer to the question, “Can you set port forwarding on existing containers?” so I thought it would be a simple solution of making a new Docker container also port forwarded to port 80 and transferring all the files over. However, when I do the “docker run” command with “-p 80:80”, it never shows the port forwarding when I do “docker ps.”
The original container had Apache2 installed on it. I had also installed Apache 2 on the host machine, but removed it (or most of it, anyway) when I got error messages saying I couldn’t restart the container because of some strange issue related to Apache on the host machine. I’m not sure if that has anything to do with it.
The kernel version is Kernel Version: 4.14.71-v7+.


(Jica) #2

May be port 80 is in use? can you execute netstat to check that? ps -a returns a running apache on the raspoberry host?

Also, you can try to connect to this port from the raspberry, I don’t know which commands are available may be curl http://localhost:80 or telnet localhost 80.

You may execute docker ps -a and remove all stale containers.