Benjamin Alexander faced an issue with a Docker image not having a port for the listener. He resolved it by adding port 8080. How can one expose a port for a listener in a Docker container?
Benjamin Alexander
Asked on Feb 22, 2024
-p
flag in the docker run
command to expose a port from the container to the host environment.hostPort:containerPort/tcp
.Example:
docker run -d -p 8080:8080/tcp my_image_name
This command exposes port 8080 from the container to the host environment.