How to resolve the issue of Docker containers running without ports?

If the container is not running with a specified port, you will need to restart the container and specify the port mapping.

You can use the following command to restart the container and specify port mapping:

docker run -d -p <host_port>:<container_port> <image_name>

In this case, represents the host port, represents the container port, and represents the name of the container image.

For example, to restart a container named my_container and map port 80 of the container to port 8080 on the host, you can use the following command:

docker run -d -p 8080:80 my_container
Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds