1

I created two docker containers of which one was of network type none and the other was of type bridge. I mapped their ports with that of host port using the following command during the creation of the docker containers.

docker run -p host_port:container_port image

The none type coontainers were added to a network using pipework and hence the none type containers also have IP addresses and can connect to the external networks.

I tried accessing the container port using netcat, but I couldn't access the port of the container which is of type none. Using the command "docker port container_name" I couldn't see the port in the none type container but I could see the mapped port of the bridge type container.

Netcat commands which I used were:

nc -l localhost host_port ----->in the host

nc localhost container_port ----->in the container

and vice versa.

Community
  • 1
  • 1
Nived
  • 11
  • 2
  • containers of type none: This mode will not configure any IP for the container and doesn’t have any access to the external network as well as for other containers. It does have the loopback address and can be used for running batch jobs. – lvthillo Jan 31 '18 at 09:20

1 Answers1

0

Docker network - None, will not configure any IP for the container and doesn’t have any access to the external network as well as for other containers. It does have the loopback address and can be used for running batch jobs.

# docker run -it --network=none ubuntu:14.04 /bin/bash
root@66308c6686be:/# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# 

# docker inspect 66308c6686be | grep -i ipaddr
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "",

For more information on docker network refer here.

Here_2_learn
  • 5,013
  • 15
  • 50
  • 68