what is network namespace and how we can access network namespace for the container

0 votes

Hi Team,
Please help me to understand what is network namespace and how we can access network namespace for the container? What is the use of network namespace?
How will I run a container on a specific node in docker swarm?
How will I link two containers over docker swarm?
If you have any docs related to Docker swarm, please share it.

Dec 19, 2018 in Docker by Ali
• 11,360 points
6,715 views

4 answers to this question.

0 votes
Docker uses Network namespace Technology for network isolation purposes which means each docker container has its own network namespace i.e. each container has its own IP address, own routing table, etc.

Let's first understand what network namespaces are. So basically, when you install Linux, by default the entire OS share the same routing table and the same IP address. The namespace forms a cluster of all global system resources which can only be used by the processes within the namespace, providing resource isolation.

Docker containers use this technology to form their own cluster of resources which would be used only by that namespace, i.e. that container. Hence every container has its own IP address and work in isolation without facing resource sharing conflicts with other containers running on the same system.
answered Dec 20, 2018 by Eric
0 votes

To run a container on a specific node, you can use something called filters. There are two types of filters available in docker- node filters and container filters. In this case, you need to use the node filters. In node filters, you have three types of filters - constraint, health, and containerslots. For your requirement, you'll only have to use the constraint filter and add a constraint mentioning you need to deploy the container only on a specific node. 

Use the following syntax:

docker run ... -e constraint:node==node_name ...

Where node_name is the name of that specific node on which you want to deploy the container. 

answered Dec 20, 2018 by Fez