Agenda
Containerisation
Docker
Installation
Container Commands
Earlier most of the applications are Monolithic applications.
Evolution of containers :
Physical Servers –> Hypervisors –> Virtual Machines –> Containers
Containerization is OS level Virtualisation
Container OS will not have Kernels it only has Libraries, therefore its light weight.
Below are few containerisation technologies, out of which docker is most widely used in the DevOps environments.
Meranti’s is the organization which is maintaining Docker, earlier it was Docker Inc.
On 1 GB machine also we can run Docker containers.
How to install Docker ?
Uninstall existing docker version with below command :
$ sudo apt-get remove docker docker-engine docker.io containerd runc
Below are the storage drives supported :
Docker Engine on Ubuntu supports overlay2
, aufs
and btrfs
We can install docker using repository :
$ sudo apt-get update
$sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
We need to add dockers official GDG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o/usr/share/keyrings/docker-archive-keyring.gpg
On x86_64 / amd64
echo \
“deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install docker Engine
sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
To install a specific version of docker engine
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
You can test installation of docker engine using hello world
sudo docker run hello-world
hub.docker.com has multiple images. We can download these images and use them, try to use official images.
Alpine is the smallest Linux image.
To spin an application it hardly takes few seconds in Docker
Ex : docker run -d -P leaddevops/petclinic:3
Check below command output :
$ Free -h
Below are few docker useful command
To connect to a container :
Docker exec <cotain_id>
Advantage of docker exec is with out even entering into container, we can execute commands
Ex : $ docker exec <container_id> ls
To come out of a container
Cntrl P Q
- Docker inspect gives all the details of container :
- Details of cmd/s used to launch the container
- Details of the image used
- Details of Host Ports
- Details of Networks (Network type ex : bridge, IPAddress etc)
- Environment Variables in the container
- State of the container (Status, Error, StartedAt, FinshedAt etc)
- Below command is to to see the CPU, Memory utilization of container
$ docker stats
- To see container size, created date, status, ports etc
$ docker ps -s
P : Container size is typically the size of the image.
- To permanently remove the container :
$ docker rm
- To see utilization of the system
$ docker system df
- To delete all stopped containers
$ docker container prune
- To see the activity of the container
$ docker logs <container_id>
- To see live streaming
$ docker logs -f <container_id>
When creating container we should specify what it has to do when container is started else default task will be performed.
Ex : for ubuntu container bash will run first and exit as bash is default for ubuntu.
Nginx uses port no 80
To troubleshoot port issue in a container :
$ ufw allow 8080
$ firewall-cmd –permanent –add-port=8080/tcp
$ firewall-cmd –reload
if you have any questions, you can whatsapp using WA chat icon on right corner of this website, our Sr.Advisor will be happy to help you. ( Timings : 9 PM to 10:30 AM PST / 9 AM to 11 PM IST)