Container

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Containerization


Why Virtualization and Linux Containers

Introduction to Docker

Installing and Managing Docker

Docker pull, run, attach

Exploring Docker hub

Pulling images from hub

AP2V Solutions Private Limited
What’s Virtualization?

- Refers to the act of creating a virtual (rather than actual) version of


something including virtual computer hardware platforms, storage devices, and
computer network resources

2
Without VMs vs With VMs

3
Benefits of virtualization

- Less heat buildup


- Reduced cost
- Faster redeploy
- Easier backups
- Better disaster recovery
- Better testing
- many more...

4
Virtualization Server Softwares

- VMware vSphere - OpenVZ


- Hyper-V - Red Hat Virtualization
- Oracle VM - Apache VCL
- XenServer - DataSphere
- vCloud Director - IBM z/OS Platform for
- Proxmox VE Apache Spark
- KVM - Pivot3 vSTAC OS
- Xen Project - UCS Virtual Machine Manager
- Virtuozzo - Virtkick
- LXC - Virtual Private Servers
- Nutanix Acropolis - Voxility

5
What’s Containerization?

- It’s an OS-level virtualization


- It’s method used to deploy and run distributed applications without launching
an entire virtual machine (VM) for each app
- The most common app containerization technology is Docker
- Docker is an open source Engine and containerd based on universal runtime
runC

6
Virtal machines vs Containers

7
What’s Docker?

- It’s a software technology providing containers, promoted by the company


Docker, Inc.
- Original author : Solomon Hykes
- Developer : Docker, Inc.
- Initial release 13 March 2013
- Written in Go
- Provides an additional layer of abstraction and automation of operating-
system-level virtualization on Windows and Linux
- It uses the resource isolation features of the Linux kernel such as cgroups and
kernel namespaces

8
What’s DockerHub?

- Docker Hub is a cloud-based repository


- Docker users and partners create, test, store and distribute container images
in DockerHub
- The users can access public, open source image repositories
- The user can create their own private repositories

9
Installation Docker Prerequisites

add the GPG key for the official Docker repository to the system:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key
add -

add the Docker repository to APT sources:



sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

update the package database with the Docker packages from the newly added
repo:

sudo apt-get update

10
Verify the Prerequisites

- Make sure you are about to install from the Docker repo instead of the default
Ubuntu 16.04 repo:

apt-cache policy docker-ce
docker-ce:

Installed: (none)

Candidate: 17.03.1~ce-0~ubuntu-xenial

Version table:

17.03.1~ce-0~ubuntu-xenial 500

500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

17.03.0~ce-0~ubuntu-xenial 500

500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

11
Install Docker


sudo apt-get install -y docker-ce

Check that it's running:



sudo systemctl status docker

12
Using the Docker Command


docker [option] [command] [arguments]

To view all available subcommands, type:



docker

13
Working with Docker Images .. to be continued

To check whether you can access and download images from Docker Hub, type:

docker run hello-world

You can search for images available on Docker Hub:



docker search ubuntu

You can download it to your computer:



docker pull ubuntu

14
Working with Docker Images

Run a container using the downloaded image:



docker run ubuntu
Note: If an image has not been downloaded when docker is executed with
the run subcommand, the Docker client will first download the image.

To see the images that have been downloaded to your computer, type:

docker images

15
Running a Docker Container

Let's run a container using the latest image of Ubuntu. The combination of the
-i and -t switches gives you interactive shell access into the container:

docker run -it ubuntu
Your command prompt should change to reflect the fact that you're now
working inside the container. (Ctrl+p) + (Ctrl+q) to exit from containers

Let’s update an image by installing the Apache



apt-get update

apt-get install -y apache2
Note: When you start up a Docker image, you can create, modify, and
delete files just like you can with a virtual machine. The changes that you
make will only apply to that container. You can start and stop it, but once
you destroy it with the docker rm command

16
Committing Changes in a Container

To save the state of the container as a new image, first exit from it:

exit

commit the changes to a new Docker image:



docker commit -m "The image from AP2V DevOps training" -a "AP2V
Solutions" container-id repository/my_application_image
Note: When you commit an image, the new image is saved locally

Listing the Docker images now on your computer



docker images
Above command should show the new image created by you

17
Listing Docker Containers

To view the active ones



docker ps

To view all containers



docker ps -a

To view the latest container you created



docker ps -l

Stopping a running or active container



docker stop container-id

18
Pushing Images to Repository

- You need an account on Docker Hub. Please create one by registering yourself
at https://hub.docker.com

Log into Docker Hub



docker login -u ap2vsolutions

Push your own image



docker push docker-registry-username/my_application_image
It should be listed on your account's dashboard

19
Lets see practical.

20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy