Docker Lab Assignment – Vijay Kesoju

Step 1 - Register a site to POST assignment and share with the trainer and for self notes(Completed - Vijay Kesoju)

Step 2 - Pre Test using LMS(Completed) Sent email to shiva@palmeto.co.in on Monday

Install Docker

 sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    5  sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    6  sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    7  sudo yum-config-manager --enable rhui-REGION-rhel-server-extras
    8  sudo yum install -y docker-ce
    9  docker -v

 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b2
 runc version: v1.0.0-0-g84113ee
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1160.31.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 3.701GiB
 Name: localhost.localdomain
 ID: 7AYB:MEZD:HDTY:MEA3:G4PJ:RE3Y:EXRC:5DAW:UVJ7:J6GR:PZRY:UYFO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: vjbhel338
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false


[root@localhost ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Assignment 1

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND              CREATED          STATUS          PORTS     NAMES
66299bc437df   ubuntu    "bash"               13 minutes ago   Up 13 minutes             focused_hertz
4b8bdbaac485   httpd     "httpd-foreground"   41 minutes ago   Up 36 minutes   80/tcp    compassionate_borg
ae1d96da3bf2   httpd     "httpd-foreground"   41 minutes ago   Created                   gracious_blackburn
[root@localhost ~]# docker attach 66299bc437df
root@66299bc437df:/# apt update
Reading state information... Done

apt-get update - To install all packages
apt-get install git
apt-get install apache2

2 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@66299bc437df:/# apt install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates git-man krb5-locales less libasn1-8-heimdal libbrotli1 libbsd0 libcbor0.6 libcurl3-gnutls libedit2 liberror-perl libexpat1 libfido2-1
  libgdbm-compat4 libgdbm6 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3
  libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common libnghttp2-14 libperl5.30 libpsl5 libroken18-heimdal librtmp1 libsasl2-2
  libsasl2-modules libsasl2-modules-db libsqlite3-0 libssh-4 libssl1.1 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 netbase
  openssh-client openssl patch perl perl-modules-5.30 publicsuffix xauth
Suggested packages:
  gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn gdbm-l10n krb5-doc krb5-user
  libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql keychain libpam-ssh monkeysphere
  ssh-askpass ed diffutils-doc perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl
The following NEW packages will be installed:
  ca-certificates git git-man krb5-locales less libasn1-8-heimdal libbrotli1 libbsd0 libcbor0.6 libcurl3-gnutls libedit2 liberror-perl libexpat1 libfido2-1
  libgdbm-compat4 libgdbm6 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3
  libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common libnghttp2-14 libperl5.30 libpsl5 libroken18-heimdal librtmp1 libsasl2-2
  libsasl2-modules libsasl2-modules-db libsqlite3-0 libssh-4 libssl1.1 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 netbase
  openssh-client openssl patch perl perl-modules-5.30 publicsuffix xauth
0 upgraded, 56 newly installed, 0 to remove and 2 not upgraded.
Need to get 19.7 MB of archives.
After this operation, 110 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
root@66299bc437df:/# git version
git version 2.25.1

root@a156efd74d8b:/# apt install apache2
Reading package lists... Done
root@a156efd74d8b:/# apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2021-07-05T07:16:56
root@a156efd74d8b:/#

command to exit from ubuntu 
control + p + q with bash

[root@localhost ~]# docker exec 66299bc437df git --version
git version 2.25.1
[root@localhost ~]#

Assignment 2#

[root@localhost ~]# docker run -d -p 8080:80 httpd
e8add1cc9743f45c18759f88b087c39e30fa6d45400c5234e2ae51b2eb9b5c02
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND              CREATED             STATUS             PORTS                                   NAMES
e8add1cc9743   httpd     "httpd-foreground"   9 seconds ago       Up 8 seconds       0.0.0.0:8080->80/tcp, :::8080->80/tcp   dazzling_blackwell
a156efd74d8b   ubuntu    "bash"               17 minutes ago      Up 17 minutes                                              elastic_hodgkin
de2b22b791c9   httpd     "httpd-foreground"   30 minutes ago      Up 30 minutes      0.0.0.0:80->80/tcp, :::80->80/tcp       wonderful_visvesvaraya
66299bc437df   ubuntu    "bash"               57 minutes ago      Up 57 minutes                                              focused_hertz
4b8bdbaac485   httpd     "httpd-foreground"   About an hour ago   Up About an hour   80/tcp                                  compassionate_borg
[root@localhost ~]# curl http://192.168.2.47:8080
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]#

Assignment 3#

To check local registry
Docker info

[root@localhost ~]# docker info
Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b2
 runc version: v1.0.0-0-g84113ee
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1160.31.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 3.701GiB
 Name: localhost.localdomain
 ID: 7AYB:MEZD:HDTY:MEA3:G4PJ:RE3Y:EXRC:5DAW:UVJ7:J6GR:PZRY:UYFO
 Docker Root Dir: /var/lib/docker


[root@localhost docker]# ls
buildkit  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes
[root@localhost docker]# ls
buildkit  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes
[root@localhost docker]# cd image
[root@localhost image]# ls
overlay2
[root@localhost image]# cd overlay2
[root@localhost overlay2]# ls
distribution  imagedb  layerdb  repositories.json
[root@localhost overlay2]# cd imagedb
[root@localhost imagedb]# ls
content  metadata
[root@localhost imagedb]# cd content
[root@localhost content]# ls
sha256
[root@localhost content]# cd sha256
[root@localhost sha256]# ls
bd29370f84eac6a9fa5373f8ed702f66820e784e5f680b62670af9f851017c96  c29284518f497b8c5f49933e74e43ca5221e69c8251e780427f7d12f716625ff
[root@localhost sha256]# ls -lrt
total 16
-rw-------. 1 root root 8701 Jul 21 02:47 bd29370f84eac6a9fa5373f8ed702f66820e784e5f680b62670af9f851017c96
-rw-------. 1 root root 1462 Jul 21 03:29 c29284518f497b8c5f49933e74e43ca5221e69c8251e780427f7d12f716625ff
[root@localhost sha256]#


Pause/Unpause-----
The docker pause command suspends all processes in the specified containers. docker pause would still keep memory portion while the container is paused. This memory is used when the container is resumed. 
The docker unpause command un-suspends all processes in the specified containers

Docker Stop/Kill
A docker STOP command issues a terminate signal to the main process running within the container and docker will have 10 seconds to clean up like saving files or emitting some message , while KILL command issues a SIGKILL signal to the process to kill one or more containers.

Share Assignment with Trainer

  • Create a POST and Send a URL of post in Zoom Chat.
  • Of Assignment#1 – Assignment#2 – Assignment#3 in one post
  • Post title can be of your choice