Author: Sahil Suri

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 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 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

Common Docker image and container management commands

Introduction The docker command now consists of multiple management commands having related sub-commands embedded within them. Some of the examples of management commands are builder, config, container, image, network, etc. You could view the full list of management commands available with docker by typing docker –help. In this article, we’ll discuss the sub-commands associated with two of the management commands namely image and container as we are likely to use them the most while working with docker. We’ll start with docker images. To view a list of available commands with the docker image command type docker image –help. List images: To list images we use docker image ls. [sahil@linuxnix ~]$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE [sahil@linuxnix ~]$ Download an image: From the docker image ls command output, we determined that we don’t have any image on the system. So, let’s download an image using the docker image pull command. [sahil@linuxnix ~]$ docker image pull nginx Using default tag: latest latest: Pulling from library/nginx f5d23c7fed46: Pull complete 918b255d86e5: Pull complete 8c0120a6f561: Pull complete Digest: sha256:eb3320e2f9ca409b7c0aa71aea3cf7ce7d018f03a372564dbdb023646958770b Status: Downloaded newer image for nginx:latest Here we pulled an image comprising the nginx web server installed from the Docker Hub. We’ll talk in detail about what happens during an image pull in a separate post docker images. Fetch image details: To view details about an image type docker image...

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.