Sunday, June 28, 2020

Docker Compose Cheat Sheet || Docker Captain || Astute JS

# Making It Easier with Docker Compose: The Multi-Container Tool

## Docker Compose and The Docker-compose.yml File

docker-compose.yml

https://docs.docker.com

## Trying Out Basic Compose Commands

pcat docker-compose.yml

docker-compose up

docker-compose up -d

docker-compose logs

docker-compose --help

docker-compose ps

docker-compose top

docker-compose down

## Assignment Answers: Build a Compose File for a Multi-Container Service

docker-compose.yml

docker pull drupal

docker image inspect drupal

docker-compose up

https://hub.docker.com

docker-compose down --help

docker-compose down -v

## Adding Image Building to Compose Files

docker-compose.yml

docker-compose up

docker-compose up --build

docker-compose down

docker image ls

docker-compose down --help

docker image rm nginx-custom

docker image ls

docker-compose up -d

docker image ls

docker-compose down --help

docker-compose down --rmi local

## Assignment Answers: Compose for Run-Time Image Building and Multi-Container Dev

docker-compose up

docker-compose down

docker-compose up


version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

Saturday, June 27, 2020

Docker Volume commands || Cheatsheet || Astute JS

# Container Lifetime & Persistent Data: Volumes, Volumes, Volumes

## Persistent Data: Data Volumes

docker pull mysql

docker image inspect mysql

docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True mysql

docker container ls

docker container inspect mysql

docker volume ls

docker volume inspect TAB COMPLETION

docker container run -d --name2 mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True mysql

docker volume ls

docker container stop mysql

docker container stop mysql2

docker container ls

docker container ls -a

docker volume ls

docker container rm mysql mysql2

docker volume ls

docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql

docker volume ls

docker volume inspect mysql-db

docker container rm -f mysql

docker container run -d --name mysql3 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql

docker volume ls

docker container inspect mysql3

docker volume create --help

## Persistent Data: Bind Mounting

cd dockerfile-sample-2

pcat Dockerfile

docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx

docker container run -d --name nginx2 -p 8080:80 nginx

docker container exec -it nginx bash

## Assignment Answers: Edit Code Running In Containers With Bind Mounts

docker run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve


The what and why of Docker - Towards Data Science

Docker Popular Image Commands || Cheatsheet || Astute Js

# Container Images, Where To Find Them and How To Build Them

## The Mighty Hub: Using Docker Hub Registry Images

http://hub.docker.com

docker image ls

docker pull nginx

docker pull nginx:1.11.9

docker pull nginx:1.11

docker pull nginx:1.11.9-alpine

docker image ls

## Images and Their Layers: Discover the Image Cache

docker image ls

docker history nginx:latest

docker history mysql

docker image inspect nginx

The what and why of Docker - Towards Data Science

## Image Tagging and Pushing to Docker Hub

docker image tag -- help

docker image ls

docker pull mysql/mysql-server

docker image ls

docker pull nginx:mainline

docker image ls

docker image tag nginx sathishkrcs/nginx

docker image tag --help

docker image ls

docker image push sathishkrcs/nginx

docker --help

docker login

cat .docker/config.json

docker image push sathishkrcs/nginx

docker image push sathishkrcs/nginx sathishkrcs/nginx:testing

docker image ls

docker image push sathishkrcs/nginx:testing

docker image ls

## Building Images: The Dockerfile Basics

cd dockerfile-sample-1

vim Dockerfile

## Building Images: Running Docker Builds

docker image build -t customnginx .

docker image ls

docker image build -t customnginx .

## Building Images: Extending Official Images

cd dockerfile-sample-2

vim Dockerfile

docker container run -p 80:80 --rm nginx

docker image build -t nginx-with-html .

docker container run -p 80:80 --rm nginx-with-html

docker image ls

docker image tag --help

docker image tag nginx-with-html:latest sathishkrcs/nginx-with-html:latest

docker image ls

docker push

## Assignment Answers: Build Your Own Dockerfile and Run Containers From It

cd dockerfile-assignment-1

vim Dockerfile

docker build cmd

docker build -t testnode .

docker container run --rm -p 80:3000 testnode

docker images

docker tag --help

docker tag testnode sathishkrcs/testing-node

docker push --help

docker push sathishkrcs/testing-node

docker image ls

docker image rm sathishkrcs/testing-node

docker container run --rm -p 80:3000 sathishkrcs/testing-node

Sunday, June 21, 2020

Red Hat Certified Systems Administrator exam | Question and Answers | AstuteJs


You need to set the execute bit on the finance directory and any subdirectories it might contain, but not on the files within them. This change must apply to all users. What methods might you use?


chmod a+X -R finance


Which directory contains the info files from which the info program reads?


/usr/share/info


What command would you use to install the star utility?


yum install star


How would you dump the contents of the /var/log/messages file into standard output, grep for all lines that contain "Memory" and then redirect the grep'ed result to /home/user/log.txt?


cat /var/log/messages | grep -i memory > /home/user/log.txt


You need to search the man pages that relate to the posix service.  What is one command that you could do to do this?


apropos postfix


How would you append the text "service=on" to the /etc/motd file?


echo "service=on" >> /etc/motd





Red Hat Certified Systems Administrator | Operate Running Systems Question and Answers | Cheatsheet


Which command display available systemd unit types?
Ans: systemctl -t help

Which command(s) would reboot the system five minutes from now and notify all users on the system of the impending reboot?
Ans: shutdown -r +5 rebooting!

Which command would not perform a reboot on the system?
Ans: systemd reboot

Which command would not power off the system?
Ans: systemd poweroff

Which command(s) would move the system into the graphical.target?
Ans: systemctl isolate graphical.target

Which command(s) would list all service unit configuration files regardless of whether they are active or not?
Ans: systemctl --type=service --all

How can you list all failed service unit configuration files?
Ans: systemctl --failed --type=service

How can you list the active state of all loaded service unit configuration files?
Ans: systemctl list-units --type=service

How do you view the disabled/enabled settings of all units with the type "service"?
Ans: systemctl list-unit-files --type=service

Which man page shows information about unit configuration files and their locations?
Ans: systemd.unit

Which man page shows specific configuration options for a service unit configuration?
Ans: man systemd.service

How do you find all man pages associated with systemd?
Ans: apropos systemd

Which command(s) would list unit configuration files that are dependencies for the network target?
Ans: systemctl list-dependencies network.target

Which command(s) would show all available targets on the system?
Ans: systemctl list-unit-files --type=target

If your system is currently in the graphical.target, which command(s) would move it out of the graphical.target and into the multi-user.target?
Ans: systemctl isolate multi-user.target

What line in the bootloader entry do you need to edit after interrupting the boot process to change the current boot target?
Ans: linux16

As part of the application build-out on your Red Hat 7 Enterprise system, you have a process that is running backend maintenance tasks. These maintenance tasks are not important and shouldn't take priority over other tasks on the system. How might you tell the system to assign CPU usage to this process only after other higher priority items have been completed or only if they do not need the CPU?
Ans: Set the nice priority to 19 on the process using renice, nice or top.

Which "niceness" is the least favorable for a process?
Ans: 19

What is the percentage load average for the following processor count and given load for the 5 minute load average?

[root@localhost]# uptime
 09:55:50 up 16:35,  3 users,  load average: 4.05, 3.03, 3.75
[root@localhost ~]# grep "model name" /proc/cpuinfo | wc -l
5

Ans:60%

Which command displays all available kill signals?
Ans: kill -l

Which command creates or updates the manual page index caches; something you should run after installing new man pages
Ans: mandb

Sunday, June 14, 2020

Revoke/Revert Git Commits from Remote or Local Repository || GIT Users must know

Developers use source control management tools like GIT or SVN daily and commits there code frequently(frequent commit is the good practice though) to avoid losing the code.
But there may be a circumstances we tend to commit the changes which is not relevant or wrong commits. In order to overcome this scenario GIT provides the powerful commands to revoke the changes made locally or even pushed to remote.
Lets see the commands to rollback the GIT commits from Local and Remote branches.
Below are the typical GIT commands to perform the GIT commits

#incrementally add the changes to GIT index before commit.
git add <filename> or git add * 

#Commit the added index to local repository
git commit -m "Good developers write meaningful commit messages"

#Logs all the commit logs of the repo
git logs

#List changes or index added on your workspace
git reflog


#Remove files added to index before commit
git rm <filename>

#Undo the Local commits
git reset --soft HEAD^     # Use --soft if you want to keep your changes
git reset --hard HEAD^     # Use --hard if you don't care about keeping the changes you made

So far we had seen the local commits and roll backing the changes, Now if the Changes are pushed to remote repository and undo the changes Lets wee whats needs to be followed.

#You are reverting the changes from the public repository , You should be very careful when executing the below command.. Below command is forcing the old reference as the recent change in the GIT.

git push -f origin last_known_good_commit:branch_name

Diagram depicts the GIT commit to local and remote workflow