Docker port map5/11/2023 ![]() Use the following to connect to the running container: If everything looks correct and you're still not able to get a response then it's time to connect to the container to see whether the application itself is listening on the specified port. The following two commands are not the same thing:ĭocker run -d -p 80:80 (Right) Everything looks okay but it still doesn't work Double check that your Docker run command is correct and that the -p argument is in the right place!īeware you can't specify the -p parameter anywhere. If you notice that the ports column for your container is empty or says something like 80/tcp then be aware that the port binding has not been set up correctly. This is saying that 0.0.0.0:80 (the host IP address from the container's perspective) on port 80 is being routed -> to port 80 on the container for the tcp protocol. If the status is Up X seconds then it's alive! Great news! Let's take a look at the ports column.Ī good port binding for 80 will look something like 0.0.0.0:80->80/tcp. The logs of the container might be able to give you a bit more information with docker logs. This could mean that your application shut down prematurely or an error occurred that caused it to fail. If you can see your container in the output from docker ps -a what does the status say? If it says Exited (0) X seconds ago then it looks like the main process exited. I can see my container in the output list Which means that the host is already allocated that port to another application or Docker container. Also check the output for the start command, you may see something like:īind for 0.0.0.0:80 failed: port is already allocated. You may want to check your command is correct for starting your container. If it isn't there then it's likely that it didn't start correctly. Take a look at what's runningĭo you see your container running in the output list? If you notice that a mapped port is taking too long to respond or not working then there are a number of steps you can take to see what's going wrong.
0 Comments
Leave a Reply. |