web analytics

Category Misc

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
    docker.io/library/busybox:old
  2. Verify the image
    [abc@host ~]$ sudo docker images
    REPOSITORY TAG    IMAGE ID     CREATED    SIZE
    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
new-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

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

[local_yum]
name=local_yum
baseurl=file:///downloaded_packages/
gpgcheck=0
enabled=1

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

Securing Solr Admin Console

The solr admin console, by default, is not secured or password protected. Anyone with the link can access all the details in the console. This post describes the steps required to secure the console. The post assumes that you followed the steps in the following two posts to

  1. Install Java and Jetty in the server
  2. Install Solr in the server

Our jetty installation is at /opt/jetty which is our java web server. Our solr installation is at /opt/solr which is our search platform.

We need to modify the following three files in order to secure the admin console.

  1. /opt/jetty/etc/jetty.xml
  2. /opt/jetty/etc/webdefault.xml
  3. /opt/jetty/etc/realm.properties

If you are not sure which files are to be edited, run the following command in the server and check for java_home variable...

Read More

Install solr with jetty in Ubuntu

Solr is a search platform which is built on Apache Lucene. It makes search easier and faster. Solr can be installed along with tomcat or jetty. This post explains the installation based on jetty.

First you should install java and jetty as mentioned in the link here.

We will install solr also in /opt. First download the latest version of solr from https://archive.apache.org/dist/lucene/solr/

I am going to download version 4.10.4. Once downloaded, uncompress it and copy the war file from dist directory to jetty webapps folder.

[root@test ~]#cd /opt

[root@test ~]# wget https://archive.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz

[root@test ~]# tar -xzvf solr-4.10.4.tgz

[root@test ~]#cp  solr-4.10.4/dist/solr-4.10.4.war   /opt/jetty/webapps/solr.war

Now, a few more files need to be ...

Read More

Installing Jetty in Ubuntu 14.04

Jetty is a java web server like tomcat, and java servlet container. This post describes how to install the latest version of Jetty in Ubuntu.

Latest version of Jetty can be downloaded from http://download.eclipse.org/jetty/stable-9/dist/

Jetty requires java and hence the first step is to install java. The latest version of Jetty, as of this writing is Jetty 9.3.8. Check the link here which shows what version of Java is required for the version of Jetty you are installing. If the version of Java does not match the version in which Jetty is compiled, then it will result in version conflict and Jetty will fail to start.

I am going to install Jetty 9.3.8, hence I need JVM 1.8. Login to your ubuntu machine and switch to root. Then issue the following commands to install java in the server.

[ro...

Read More