Skip to main content

Docker project

Since last few weekend I am learning Docker. A great initiative from Linux word under IIEC Rise and guidance of Vimal Daga. At the completion of this training I have implemented container technology and created my own monitoring system(Moatis).

Project steps:-
  1. Pull centos:7 image
  2. I created a volume for persistent storage 
  3. Launched a container
  4. Exposed it to public
  5. Login into newly created centos container
  6. Deployed Nagios
  7. Setup monitoring on few hosts
  8. Tested if each and everything is working fine or not.
Please check below for all the commands which I have executed to complete this project.
Commands I have executed on Container Host - 
  176  podman container ls
  177  podman container ls -a
  178  podman image ls
  179  podman volume create mymoatis
  180  podman volume inspect mymoatis
  181  cd /var/lib/containers/storage/mymoatis/_data/
  182  ls
  183  podman volume rm mymoatis
  184  podman volume ls
  185  podman volume create moatis_storage
  186  podman volume ls
  187  podman container run -dit --name my_moatis -v moatis_storage:/var/local/nagios -p 8080:80 docker.io/library/centos
  188  podman image ls
  189  podman container run -dit --name my_moatis -v moatis_storage:/var/local/nagios -p 8080:80 docker.io/library/centos:7 docker.io/library/centos:7
  190  podman container ls
  191  podman container ps -a
  192  podman container rm 4c238f3ca3bb
  193  podman container ps -a
  194  podman container run -dit --name my_moatis -v moatis_storage:/var/local/nagios -p 8080:80 docker.io/library/centos:7 docker.io/library/centos:7
  195  podman container ps -a
  196  podman attach e41614fe7b4d
  197  podman container start e41614fe7b4d
  198  podman image ls
  199  podman container rm 4c238f3ca3bb
  200  podman container rm e41614fe7b4d
  201  podman container ps -a
  202  podman image ls
  203  podman container run -dit --name my_moatis -v moatis_storage:/var/local/nagios -p 8080:80 docker.io/library/centos:7
  204  podman container ps -a
  205  podman attach 262f0db5af65
  206  podman container run -dit --privileged=true --name my_moatis1 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis1:1
  207  podman attach my_moatis1
  208  podman container rm 3a95724d16c58a385ff31ca88fccd5b8e58b012e25af2cc0d1a0e0a65131a67b
  209  podman container run -dit --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name my_moatis1 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis1:1
  210  podman container rm my_moatis1
  211  podman container run -dit --privileged /usr/sbin/init --name my_moatis1 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis1:1
  212  podman container run -dit --privileged IMAGE /usr/sbin/init --name my_moatis1 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis1:1
  213  podman container run -dit --privileged=true --name my_moatis1 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis1:1 bash
  214  ifconfig enp0s3
  215  podman container ps -a
  216  systemctl status httpd
  217  yum install httpd
  218  yum install http -y
  219  yum repolist
  220  dnf install http -y
  221  dnf install httpd -y
  222  df -hT
  223  cat /etc/yum.repos.d/my.repo
  224  df -hT
  225  yum repolist
  226  dnf install httpd -y
  227  yum repolist
  228  dnf clean all
  229  dnf repolist
  230  dnf cleanall
  231  dnf repolist
  232  dnf clean all
  233  dnf repolist
  234  dnf install httpd -y
  235  systemctl status httpd
  236  systemctl start httpd
  237  systemctl status httpd
  238  view /usr/lib/systemd/system/httpd.service
  239  podman image ls
  240  podman container commit my_moatis1 my_moatis2
  241  podman image ls
  242  podman container run -dit --privileged=true --name my_moatis2 -v moatis_storage:/var/local/nagios -p 8080:80 localhost/my_moatis2:latest  /usr/sbin/init
  243  systemctl status httpd
  244  systemctl enable httpd
  245  systemctl restart httpd
  246  systemctl status httpd
  247  cd /root/nagios
  248  ping 5786a768776f
  249  ifconfig
  250  ifconfig enp0s3
  251  podman container commit my_moatis2
  252  podman container commit my_moatis2 nagios_final
  253  podman image ls

Commands executed on Moatis container -
[root@5786a768776f objects]# history
    1  systemctl
    2  systemctl
    3  systemctl status httpd
    4  systemctl start httpd
    5  systemctl enable httpd
    6  cd /root/
    7  ls
    8  cd nagios/
    9  ls
   10  ls -ld
   11  ls -l
   12  cd nagios-plugins-2.2.1
   13  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
   14  make
   15  make install
   16  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
   17  systemctl enable nagios
   18  systemctl enable httpd
   19  systemctl start nagios.service
   20  ping 192.168.1.8
   21  history
   22  nagios check
   23  vim /usr/local/nagios/etc/objects/localhost.cfg
   24  ifconfig
   25  vim /usr/local/nagios/etc/objects/localhost.cfg
   26  cd /usr/local/nagios/etc/objects/
   27  grep -irow localhost .
   28  vim vim localhost.cfg
   29  ls
   30  vim localhost.cfg
   31  vim localhost.cfg
   32  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
   33  vim /usr/local/nagios/etc/objects/localhost.cfg
   34  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
   35  systemctl reload nagios
   36  /usr/local/nagios/libexec/check_icmp -H 10.88.0.10
   37  systemctl status sshd
   38  yum install openssh-server -y
   39  systemctl status sshd
   40  systemctl start sshd
   41  systemctl enable sshd
   42  systemctl status sshd
   43  /usr/local/nagios/libexec/check_http -H 10.88.0.10
   44  /usr/local/nagios/libexec/check_http --help
   45  /usr/local/nagios/libexec/check_http -H 10.88.0.10 -p 80
   46  /usr/local/nagios/libexec/check_http -H 10.88.0.10 -p 80
   47  vim /usr/local/nagios/etc/objects/localhost.cfg
   48  ls
   49  ls
   50  vim windows.cfg
   51  ping 192.168.1.2
   52  ls
   53  vim commands.cfg
   54  ping hub.docker.com
   55  history
[root@5786a768776f objects]#

Comments

Post a Comment

Please share your experience.....

Popular posts from this blog

error: db5 error(11) from dbenv->open: Resource temporarily unavailable

If rpm command is not working in your system and it is giving an error message( error: db5 error(11) from dbenv->open: Resource temporarily unavailable ). What is the root cause of this issue? How to fix this issue?   just a single command- [root@localhost rpm]# rpm --rebuilddb Detailed error message- [root@localhost rpm]# rpm -q firefox ^Cerror: db5 error(11) from dbenv->open: Resource temporarily unavailable error: cannot open Packages index using db5 - Resource temporarily unavailable (11) error: cannot open Packages database in /var/lib/rpm ^Cerror: db5 error(11) from dbenv->open: Resource temporarily unavailable error: cannot open Packages database in /var/lib/rpm package firefox is not installed [root@localhost rpm]# RPM manage a database in which it store all information related to packages installed in our system. /var/lib/rpm, this is directory where this information is available. [root@localhost rpm]# cd /var/lib/rpm ...

Failed to get D-Bus connection: Operation not permitted

" Failed to get D-Bus connection: Operation not permitted " - systemctl command is not working in Docker container. If systemctl command is not working in your container and giving subjected error message then simple solution of this error is, create container with -- privileged option and also provide init file full path  /usr/sbin/init [root@server109 ~]# docker container run -dit --privileged --name systemctl_not_working_centos1 centos:7 /usr/sbin/init For detailed explanation and understanding I am writing more about it, please have look below. If we have a daemon based program(httpd, sshd, jenkins, docker etc.) running inside a container and we would like to start/stop or check status of daemon inside docker then it becomes difficult for us to perform such operations , because by default systemctl and service  commands don't work inside docker. Normally we run below commands to check services status in Linux systems. [root@server109 ~]# systemctl status ...

AWS cloud automation using Terraform

In this post I'll create multiple resources in AWS cloud using Terraform . Terraform is an infrastructure as code( IAC ) software which can do lots of things but it is superb in cloud automation. To use Terraform we have write code in a high-level configuration language known as Hashicorp Configuration Language , optionally we can write code in JSON as well. I'll create below service using Terraform- 1. Create the key-pair and security group which allow inbound traffic on port 80 and 22 2. Launch EC2 instance. 3. To create EC2 instance use same key and security group which created in step 1 4. Launch Volume(EBS) and mount this volume into /var/www/html directory 5. Upload index.php file and an image on GitHub repository 6. Clone GitHub repository into /var/www/html 7. Create S3 bucket, copy images from GitHub repo into it and set permission to public readable 8 Create a CloudFront use S3 bucket(which contains images) and use the CloudFront URL to update code in /var/w...