Docker installation on Centos8 using images distributed via Docker hub

Step1:

Check for existing docker installations and remove if any.

sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine

Step2:

Install yum utilities and collections package.

sudo yum install -y yum-utils

Step3:

Add the docker repo to yum config manager. 

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Step4:

Install the latest version of Docker Engine.

sudo yum install docker-ce docker-ce-cli

Step5:

Check docker version. If docker is installed properly, the version number will be shown.

docker --version

Step6:

Download current stable version of Docker Compose.

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

Step7:

Give Executable permissions to the binaries. 

chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

Step8:

Check docker compose version.

docker compose version

Step8:

Inside the /home/zetarisuser folder make the following directories and subdirectories.

mkdir db
mkdir data
mkdir solr
cd solr
mkdir cores
cd cores
mkdir metadata
mkdir content
cd content
mkdir data
cd ../metadata
mkdir data
cd ../../..
cd docker

Step9:

Make a group ‘docker’

sudo groupadd docker

Step10:

Modify user account zetaris to access the docker group

sudo usermod -aG docker zetaris

Step11:

Make a file named docker-compose.yml and give necessary permissions

touch docker-compose.yml

Step 12:

Give necessary permissions to the docker-compose.yml file 

chmod 775 docker-compose.yml

Step13:

Add the below text to the docker-compose.yml file. 

echo "version: "3.9"
services:
db:
image: <image name eg:zetaris/17feb2022>:<tag name eg:DB>
restart: always
ports:
- "5430:5432"
environment:
- POSTGRES_PASSWORD=XXX
- POSTGRES_USER=postgres
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- /home/zetarisuser/db/:/var/lib/postgresql/data
server:
image: <image name eg:zetaris/17feb2022>:<tag name eg:SERVER>
ports:
- "10000:10000"
- "9998:9998"
volumes:
- /home/zetarisuser/data:/opt/zetaris/server/lightning/data
- /home/zetarisuser/solr/cores/metadata/data:/opt/zetaris/server/lightning/solr-8.6.0/server/solr/cores/metadata/data
- /home/zetarisuser/solr/cores/content/data:/opt/zetaris/server/lightning/solr-8.6.0/server/solr/cores/content/data
depends_on:
- db
gui:
image: <image name eg:zetaris/17feb2022>:<tag name eg:GUI>
ports:
- "9001:9001"
volumes:
- /home/zetarisuser/data:/opt/zetaris/gui/lightning-gui/data
depends_on:
- server" > docker-compose.yml

Step14:

Start Docker

sudo systemctl start docker

Step15:

Docker Login

docker login -u zetRegistryPreview -p XXXX zetRegistryPreview.azurecr.io

Step16:

Aggregate output of all containers

docker-compose up

Step17:

Check the installation of 3 docker images.

docker ps -a

Step18:

Enter in a container (server or gui or db)

docker exec -it <image-id> bash

If we are running individual images as containers using the docker run commands, we can use the below flags. To allow and run the containers with full permissions we can set the user as root.

Docker privileged mode grants a Docker container root capabilities to all devices on the host system. Running a container in privileged mode gives it the capabilities of its host machine.

docker run --user root --privileged <....>