DevOps - Lab 7: Installing and Configuring Docker

Installing and Configuring Docker

In Lab 7: Installing and Configuring Docker, participants typically focus on the installation and initial setup of Docker, an open-source platform for automating the deployment, scaling, and management of containerized applications. This lab involves installing the Docker engine on the host system, configuring essential settings, and verifying the installation with basic Docker commands. Participants may explore Docker Hub for accessing container images and creating their custom images using Dockerfiles. The lab aims to provide hands-on experience in setting up Docker, enabling participants to efficiently create, deploy, and manage containerized applications. Successful completion of Lab 7 equips participants with foundational skills to leverage Docker for containerization, fostering greater flexibility and consistency in application deployment across various environments.

Lab:

1. Installing Docker

yum install docker -y

2. Docker basic commands

//To check the docker version
docker --version

//To check the status of the service
service docker status

//To start the docker service
service docker start

//To enable the service
chkconfig docker on

//To see images present in your local machine
docker images

//To search images from online docker registry
docker search centos
docker search jenkins

//Download image from online docker registry to your machine
docker pull centos
docker pull jenkins

//To see only running containers
docker ps

//To see all containers
docker ps -a

//To create a container
docker run -i -t ubuntu /bin/bash
docker run -i -t centos /bin/bash

//run commands inside the container
hostname
cat /etc/os-release

//to exit from container
exit

//To rename a container
docker rename <old\_name>  <new\_name>
docker ps -a

// Create container by giving container name
docker run --name Cnt-1 -it centos /bin/bash

//To start container
docker start Cnt-1
docker ps

//To go inside container
docker attach Cnt-1

//run commands inside the container
touch /tmp/myfile
exit

//To see the changes
docker diff Cnt-1

//To stop container
docker stop Cnt-1

//To create image from container
docker commit Cnt-1
docker images

//To give name to your image
docker tag <image-ID> Cnt-1-img
docker images

//To give name of image while creating it
docker commit Cnt-1 <image-name>

//Create container from our image
docker run --name Cnt-2 -it Cnt-1-img /bin/bash

//run the command inside container
ls /tmp

//To delete a container
docker rm Cnt-1

//To stop all containers
docker stop $(docker ps -a -q)

//To delete all stopped containers
docker rm $(docker ps -a -q)

//To delete all images
docker rmi -f $(docker images -q)