Now, we will stop and remove the nginx02 container and create another one but this time specifying the port mapping. sudo docker inspect Ĭopy the IP address to your browser, you will find that it throws an error because we did not specify port mapping. To verify the same, try to access it through your browser by pasting the Ip address of the container. Now since we have not specified port mapping while creating the container with bridge network driver, you will not be able to access it through your local machine. You will find that inside the ports section of the nginx02 container, you will find a port number along with the protocol listed there. Now, execute the docker list command to get the details of the container. sudo docker run −d −−network bridge −−name nginx02 nginx−alpine
#Docker network ip driver
Now let’s create another nginx container using the network bridge driver without port mapping. This verifies that the nginx container is now running on the host network. You will find that now the container’s list has the nginx container details inside it. Now, inspect the host network using the following command. You will find that the list of ports for the nginx container is empty. To check whether the host network is using port mapping or not, list the containers to get the details of the ports. Inside the browser, copy this IP address and you can verify that the nginx container is running successfully. Use the below command to get the container Id. We do not specify port mapping while using the host network because the host network driver automatically uses the “eth0” when running on linux/unix systems. sudo docker container run −d −−network host −−name nginx01 nginx−alpine We will now create a nginx Docker Container with the host network. Note that the Containers object is initially empty. You will get a json list with all the details about the network. Try to inspect that network using the following command. You will find a network with the name host and driver name as host with the scope as local. Before creating a nginx container, let’s list all the available networks. To understand them better, let’s create a nginx container with the help of host networking. In the case of a bridge network, it requires port mapping to communicate. In case of a host network, a particular Docker Container can directly use the Networking of the host for sending and receiving the packets. Single−host networks mean that their effect is local to each individual host. There are two types of single−host networks available for Docker Networking - “host” and “bridge” networks.