Understanding Container Networking

nordvpn best offer nordvpn best offer

In the previous video, we learned about running a container and port mapping to access it via a web browser or the Curl tool. In this video, we will discuss container networking, IP addresses, and port mappings to avoid conflicts.

Limited IP Addresses

IP Version 4 address, which is represented by something dot something dot something dot something, has a limited number of IP addresses. Therefore, containers won’t have public IP addresses but instead have IP addresses for their services like web servers, database servers, or mail servers.

Port Mapping

Containers will expose services on a port-by-port basis, and we will be dealing with port numbers to avoid conflicts. To find out the port mapping, we can use docker ps or docker port if we know the container ID.

For instance, by using the command docker port <container_id>, we can find out the host port number for a container running on port 8000.

bashCopy code

$ docker port 302d30 8000/tcp ->

Assigning a Custom Port Number

We can assign a custom port number by specifying the -p flag followed by the mapping. For example, docker run -d -p 88:8000 <image_name> will map the host port 88 to the container port 8000.

bashCopy code

$ docker run -d -p 88:8000 <image_name>

We can verify the mapping by using the docker ps command.

$ docker ps CONTAINER ID   IMAGE          COMMAND              CREATED         STATUS         PORTS                    NAMES 302d30         <image_name>   "python"      1 minute ago    Up 1 minute>8000/tcp   gracious_mendeleev

Finding the IP Address

We can find the IP address of a container using the docker inspect command with the format option.

$ docker inspect --format '' <container_id>
$ docker inspect --format '' 302d30

However, we should remember that containers shouldn’t have public IP addresses. Instead, we should use port mapping to access services.


In conclusion, we can publish a web server inside a container, make it public, and access it from different computers by being aware of port mapping and which port number to use when accessing the service.

You might also like these blog posts

Full Bright

Full Bright

A professional and sympathic business man.


Contact Us

To order one of our services, navigate to the order service page


10 rue de Penthièvre,
75008 Paris

Email Us

hello at bright-softwares dot com

Open Hours

Monday - Friday
9:00AM - 05:00PM