web analytics

Docker re-tag images

Often there are tags with images when they are pulled. If you want to rename that tag, all you need to do is the following steps.

  1. Pull the image
  2. Re-tag the image using docker tag imagename:current_tag imagename:new_tag
  3. docker rmi image:current_tag

When you re-tag, it will leave you with two different images with different tags and we need to get rid of the old one using step3.

An example given below

  1. Pull the image
    [abc@host ~]$ sudo docker pull busybox:old
    musl: Pulling from library/busybox
    2bafa357a9a5: Pull complete
    Digest: sha256:658f4fcf74879ed5a01bf310d018099413f3b2588c1565ac54c85253ba3fc6d4
    Status: Downloaded newer image for busybox:old
  2. Verify the image
    [abc@host ~]$ sudo docker images
    busybox ...
Read More

Git conflicts – How to resolve conflicts and merge

Sometimes when you merge two git branches, it might give you conflict. Conflict occurs because the same line in the same file has been edited differently in the two branches. This confuses git as to which change to accept and merge. Git conflicts are to be always resolved manually before git can proceed with the merge.

For example, I have two different branches here named current-branch and dev-branch. I want to merge the changes in dev-branch to current-branch now but I am getting a conflict.

[root@abc]# git branch
* current-branch

[root@abc]# git merge new-branch
Auto-merging abc.txt
CONFLICT (content): Merge conflict in abc.txt
Automatic merge failed; fix conflicts and then commit the result.

Now, to resolve the conflict, you the git mergetool

If you have not already conf...

Read More

Multiple SSH identities in Git

After a long break of nearly 2 years, I tried to brush up my knowledge and wanted to started with Git. I created a bitbucket repo under my personal account, and setup the identities but no matter what, I was unable to clone the repo via ssh. I was getting the following error while trying to do it.

git clone -b master git@bitbucket.org:myusername/magento2.3.git
Cloning into ‘magento2.3’…
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The error clearly stated it was a problem with my ssh key. I already checked and confirmed the following

  1. I have added the SSH public key to the repo’s Access keys option.
  2. I also tried to add it under Personal Settings -> Security -> SSH keys but both ...

Read More

fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.”}

While creating a playbook for mysql, I cam across the following error while creating database on an AWS Amazon Linux instance.

fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.”}


To correct it, we need to install the dependencies and add them to the playbook as required below

– name: “Installing pip”
name: python2-pip
state: present

– name: “Installing pymysql for dependency”
name: pymysql
state: present

Read More

Running ansible playbook locally

To run an ansible playbook in your localhost, just add the following entry to your inventory file

localhost ansible_host= ansible_connection=local


Then, in your playbook, add localhost to the hosts section

hosts: localhost


Read More

Failed to start crond.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files

Sometimes you might come across some errors as follows, when you start services in servers.

Failed to start crond.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files 


Nothing to worry, it could just be because you don’t have the proper permission to do so, or you failed to add a ‘sudo’ infront of the command. Juts try with sudo and it will work.

[abc@greproot ~]$ sudo systemctl start crond.service
[abc@greproot ~]$ sudo systemctl status crond.service
● crond.service – Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-05-28 10:29:05 UTC; 10s ago

Read More

Create local yum repo in Centos7

To create a local yum repo, all you need to do is to make sure the packages are available in a path in the server, say /downloaded_packages/

Now, create a repo file. Be default, all repo files are present in the path /etc/yum.repos.d/ . I am going to name my repo as local_yum, so I will create a repo file named local_yum.repo and add the following contents in it.

cat /etc/yum.repos.d/local_yum.repo


The above files tells the programme to take the packages from the baseurl mentioned in the file, which in our case is our local folder /downloaded_packages/

Now check if our repo is listed correctly. In my case, I have not set any other repos, so only my local repo is listed...

Read More

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/nginx/json: dial unix /var/run/docker.sock: connect: permission denied

I was getting this error when I was trying to run a docker container using jenkins declarative pipeline script. This was being run on my localhost and below is what I needed to correct it.

Added jenkins user to docker group

sudo usermod -a -G docker jenkins

The solution that actually worked was to change the permission of the sock file to 666

devops-04:~$ ls -al /var/run/docker.sock
srw-rw—- 1 root docker 0 Oct 28 11:54 /var/run/docker.sock

devops-04:~$ sudo chmod 666 /var/run/docker.sock

devops-04:~$ ls -al /var/run/docker.sock


Once this was done my pipeline script started working!

Read More

Install PHP7.2 on Centos7

PHP 7.2 does not come by default with Centos base repo. Hence, in order to install it we first need to install and enable the remi repo and then install PHP. Execute the following commands in the below order to get PHP 7.2 installed on Centos7.

[root@de56f5fc317d ~]# yum update

[root@de56f5fc317d ~]# yum install yum-utils

[root@de56f5fc317d ~]# yum install epel-release

[root@de56f5fc317d ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

[root@de56f5fc317d ~]# yum-config-manager –enable remi-php72

Now, check if PHP 7.2 packages are available.

[root@de56f5fc317d yum.repos.d]# yum list available php72
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: centos.mirrors.nublue.co.uk
* epel: lon.mirror.rackspace.com
* extras: mirror...

Read More

mysqldump: Got error: 1449: The user specified as a definer (‘user’@’%’) does not exist when using LOCK TABLES

I came across this error while taking the database dump of a database. The database was originally created in another server and transferred to my server after long. When I tried to take a database dump as a part of my backup script, I came across this error.

mysqldump: Got error: 1449: The user specified as a definer (‘edulanche’@’%’) does not exist when using LOCK TABLES

Basically this error is caused by a definer which was created in the previous server but is not present in the new server. The easiest way to get past this error is to go to the original dump file and search for ‘definer’ in it.

/*!50013 DEFINER=`user`@`%` SQL SECURITY DEFINER */

If found, modify it to reflect the root user or database user in your new server.

/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINE...

Read More