Author: Sahil Suri

Docker Volumes explained

Introduction In earlier posts, we created a script in our container and we were able to execute it. But when the container is removed the script will get removed right along with it. What if we wanted the files created during our container lifecycle to persist after the container has been terminated? We could do so by using docker volumes which are the preferred mechanism for allowing data persistence in Docker containers. Advantages of docker volumes: They can be used on both Linux and Windows containers. We can use volume drivers to store data on a remote host or even a cloud provider. New volumes can have their content pre-populated by a container.   We’ll now walk you through a step by step process to create a docker volume and mount it in a container. Step 1: Create a docker volume. Before we create our volume let’s check the system for any existing volumes. [sahil@linuxnix ~]$ docker volume ls DRIVER VOLUME NAME [sahil@linuxnix ~]$ We’ll now create out docker volume using the docker volume create command. [sahil@linuxnix ~]$ docker volume create linuxnixvol linuxnixvol Let’s run docker volume ls again to verify that our volume has been created. [sahil@linuxnix ~]$ docker volume ls DRIVER VOLUME NAME local linuxnixvol [sahil@linuxnix ~]$ Step 2: Retrieve info about the volume [sahil@linuxnix ~]$ docker volume inspect linuxnixvol [ { "CreatedAt": "2019-07-10T08:10:00Z", "Driver": "local", "Labels":...

Read More

Docker networking commands explained

Introduction Our last article was a theoretical introduction to the Docker networking stack comprising the container network model and its components. In this article, we’ll be demonstrating some useful docker networking related commands including how to create and inspect networks in Docker. Before getting started with the docker networking commands let’s run ifconfig command on our docker host to see the adapters. [sahil@linuxnix ~]$ ifconfig -a docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet netmask broadcast ether 02:42:c1:a9:d8:99 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001 inet netmask broadcast inet6 2406:da18:77c:6102:6682:ca26:b37:c059 prefixlen 128 scopeid 0x0<global> inet6 fe80::471:43ff:fec0:81a4 prefixlen 64 scopeid 0x20<link> ether 06:71:43:c0:81:a4 txqueuelen 1000 (Ethernet) RX packets 2185 bytes 814542 (795.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2880 bytes 596702 (582.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet netmask inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 16 bytes 1036 (1.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1036 (1.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0...

Read More

Docker networking basics explained

Introduction In this post, we are going to delve in the theory and components of Docker networking. Generally, when we create a container, from the networking aspect it either needs to communicate with another container or it comprises an application that needs to communicate with the internet. Docker networking essentially consists of the following three major components: 1 Container network model: This is a design specification that outlines the fundamental building blocks of docker. 2 libnetwork: This is the real-world implementation of CNM used by Docker to communicate between containers. libnetwork is also responsible for service discovery, ingress based container load balancing and the networking management control plane functionality. 3 Drivers: libnetwork implements CNM using drivers. The drivers are used to implement different network topologies. We’ll now discuss the drivers that are used by libnetwork.   1 Bridge This is the default driver used by libnetwork. A bridged network is a link layer device that forwards traffic between different network segments. The bridge driver uses a software bridge which allows containers connected to the same bridged network to communicate with each other. It also provides a layer of isolation to containers not connected on the same network. The bridge driver only works on Linux. 2 Host If you use the host network mode for a container, that container’s network stack is not isolated from the Docker host (the container...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe


My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.