Author: Sahil Suri

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

How to push an image to Docker hub

Introduction In our previous post, we explained some of the ways we could work with containers like running commands on containers during startup and also while they were running. We also explained how to start and connect to stop containers and also how to remove stopped containers. Also, we briefly talked about images and explained how to remove an image. In this post, we will explain step by step how to push an image we created to our docker hub repository.   Step 1: Login to docker hub account In order to push an image to the Docker hub, we must first log in to our docker hub account on the system where the image is located and the docker container engine is running. [sahil@linuxnix ~]$ docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: sahilsuri008 Password: WARNING! Your password will be stored unencrypted in /home/sahil/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded [sahil@linuxnix ~]$ As you can see our login succeeded. Step 2: Tag the image to upload Let’s see the images that we have available on our system with the docker image ls command. [sahil@linuxnix ~]$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> e1c1d07a11b5 8 hours ago...

Read More

Ansible: insert a line after a string using lineinfile module

Introduction I recently came across a situation wherein I needed to search for a string/word in a file and then append some piece of text after the matched string. I’m sure that there are many ways to accomplish this using Ansible but in this post, I’ll demonstrate what I used to get this done. I’ll also show you what didn’t work so you might get an idea about what not to do if you are trying to modify text in files using lineinfile module which I found to be awesome by the way. You may refer to the official documentation for lineinfile right here. This module ensures a particular line is in a file, or replace an existing line using a back-referenced regular expression. This is primarily useful when you want to change a single line in a file only. For the purpose of this demonstration, I’ll be using a Centos 7 system with Ansible 2.8 installed on it. Let’s just verify that before we get started. [ssuri@linuxnix ~]$ cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [ssuri@linuxnix ~]$ ansible --version ansible 2.8.2 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/ssuri/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Jun 20 2019, 20:27:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] [ssuri@linuxnix ~]$ Scenario Given below is the file that I’d like to modify....

Read More

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

Email Subscribe

ABOUT ME..!

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.