Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To access both the services on the docker container and the host concurrently, you need to map the container port to the host port through port binding.

Here are the steps to follow:

  1. Start the container and expose the service port (for example, port 8080) using the -p option:
docker run -p 8080:8080 your-image-name

This maps the container port 8080 to the host port 8080.

  1. Access the service on the container using the container IP address and port number (for example, localhost:8080).

  2. Access the service on the host using the host IP address and port number (for example, <host_ip_address>:8080).

By specifying the port mapping, the container service becomes accessible from both the container IP address and the host IP address. This allows you to concurrently access the service from both the container and the host.