Nagendra- Docker LAB

Install Docker Engine in Centos#1 Vm.

[root@localhost ~]# history
1 ifconfig
2 sudo yum install -y yum-utils device-mapper-persistent-data lvm
3 udo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
4 sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
5 sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.r
6 sudo yum-config-manager –enable rhui-REGION-rhel-server-extras
7 sudo yum install -y docker-ce
8 sudo yum install docker-ce
9 docker -v
10 – Enable Docker
11 Start Docker
12 Start Docker
13 start docker
14 sudo systemctl enable docker
15 sudo systemctl start docker
16 history

Verification.

root@720751c45f2c:/# ps -eaf | grep dockerd
root 3672 1 0 13:38 pts/0 00:00:00 grep –color=auto dockerd

[root@localhost ~]# which containerd
/bin/containerd

[root@localhost ~]# ps -eaf | grep containerd
root 3110 3032 0 02:41 pts/1 00:00:00 grep –color=auto containerd
root 30400 1 0 01:36 ? 00:00:00 /usr/bin/containerd
root 30409 1 0 01:36 ? 00:00:04 /usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock

Assignment#1

[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
720751c45f2c ubuntu “bash” 46 minutes ago Exited (1) 4 minutes ago dazzling_aryabhata
684695c21d76 ubuntu “bash” About an hour ago Exited (0) About an hour ago happy_kepler

[root@localhost ~]# docker run -itd ubuntu
cb56e4630dfba75663fd09174bf1d2d555b0258a6197bdf50c7ae2173d2d5ff4
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb56e4630dfb ubuntu “bash” 15 seconds ago Up 14 seconds eloquent_hopper
720751c45f2c ubuntu “bash” 46 minutes ago Exited (1) 5 minutes ago dazzling_aryabhata
684695c21d76 ubuntu “bash” About an hour ago Exited (0) About an hour ago happy_keple

[root@localhost ~]# ^C
[root@localhost ~]# docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
b4d181a07f80: Pull complete
4b72f5187e6e: Pull complete
12b2c44d04b2: Pull complete
35c238b46d30: Pull complete

[root@localhost ~]# docker images|grep httpd
httpd latest bd29370f84ea 12 days ago 138MB

[root@localhost ~]# docker attach cb56e4630dfb
root@cb56e4630dfb:/#

[root@localhost ~]#git version

git version 2.25.1

Create an image with base – centos and git must be inst

[root@localhost ~]# cat dockerfile
[root@localhost ~]# vi dockerfile
[root@localhost ~]# cat dockerfile

M ubuntu
MAINTAINER Nagendra
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get -y install tzdata
RUN apt-get update && apt-get install git -y && apt-get install -yq apache2
CMD /usr/sbin/apache2ctl -D FOREGROUND

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
ub-up-git    latest    14ca71c606d1   28 seconds ago   259MB
ubuntu       latest    c29284518f49   7 days ago       72.8MB
httpd        latest    bd29370f84ea   12 days ago      138MB

Push a docker image to hub.docker.com

[root@localhost ~]# docker tag ub-up-git nag9779/nagendra01
[root@localhost ~]# docker images
REPOSITORY           TAG       IMAGE ID       CREATED         SIZE
ub-up-git            latest    14ca71c606d1   5 minutes ago   259MB
nag9779/nagendra01   latest    14ca71c606d1   5 minutes ago   259MB
ubuntu               latest    c29284518f49   7 days ago      72.8MB
httpd                latest    bd29370f84ea   12 days ago     138MB
[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: nag9779
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@localhost ~]#