Introduction to Containers
Intro and Basics of Containerization
● What is a Container?
● Containerization vs. Virtual Machine
● Docker Installation
● Main Docker Commands
● Building your own Containerized Image for Flask Application
Push image to Docker Hub
Learn IBM CR
Push image to IBM container registry
Applications are transforming
Application Modernization
Developer Issues:
separate operations
available by design
Traditional Deployment
Early on, organizations ran applications on physical servers.
Demerits of Traditional Deployment
Overview of deployments
How virtualization works
Virtualization is a process whereby software is used to create an abstraction layer over computer hardware that allows the hardware elements of a single computer to be divided into multiple virtual computers.
Hypervisors
A hypervisor is the software layer that coordinates VMs. It serves as an interface between the VM and the underlying physical hardware, ensuring that each has access to the physical resources it needs to execute. It
Virtual Machine vs Containerization
What is a container
Before Containers
Developer
Developer
Node js
Mongo Express
Node js
Mongo Express
After Containers
Node Container
Node Container
Where do containers images live ?
Container Registry
Private Repositories
Public Repository for Docker (Docker Hub)
https://razorops.com/blog/best-docker-image-hosting-platforms/
Key Benefits of Docker Containers
What is Docker
The Docker platform it provides the ability to package and run an application in a loosely isolated environment called a container.
What is Docker?
Docker is popular virtualization software that helps its users in developing, deploying, monitoring, and running applications in a Docker Container with all their dependencies.
Docker containers include all dependencies (frameworks, libraries, etc.) to run an application in an efficient and bug-free manner.
Docker Containers have the following benefits:
Docker architecture
Docker Installation
Steps to install Docker
Steps to install Docker
$ docker version
$ docker run -d -p 80:80 docker/getting-started
Docker main commands
$ docker run -d -p 80:80 docker/getting-started
Starting and Stopping Containers
$ docker container start <CONTAINER_NAME>
$ docker container stop <CONTAINER_NAME>
$ docker container stop <CONTAINER_ID>
Listing Docker Containers
$ docker container ls
Docker Commands
$ docker container ls -a
$ docker container ls -q
$ docker container ls -h
Inspecting and Running Containers
$ docker container inspect <CONTAINER_NAME>
$ docker container exec -t <CONTAINER_NAME> /bin/sh
Removing Containers
$ docker container rm <container ID>
$ docker container rm <container name>
Docker Images
How to create a Docker Image
Docker Image is created using Dockerfile
Dockerfile
The specific commands you can use in a dockerfile are:
FROM, PULL, RUN, and CMD
Dockerfile
A Dockerfile is simply a text-based script of instructions that is used to create a container image.
FROM python:3.10.6
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python","./app.py"]
From Flask app to docker flask
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Command : docker build -t <image_name> .
Example : docker build -t hello-world .
Next docker image was created with name
For finding images of docker we use command
Command : docker image ls -a
For Delete image
Command : docker rmi <image_name>
Docker Commands
IBM CLOUD CLI
https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli
Install, Set Up, and Log In
3. Install the Container Registry plug-in.
Working with Docker hub —----------------------------------------
$ docker tag hello-world kshyam/hello-world:latest
$ docker push kshyam/hello-world:latest
$ docker pull kshyam/hello-world:latest
Working with IBM CR —-----------------------------------------------------------
ibmcloud login
ibmcloud plugin install container-registry
ibmcloud cr login
$ docker tag hello-world jp.icr.io/ibmtrainning/hello-world:latest
$ docker push jp.icr.io/ibmtrainning/hello-world:latest
$ docker pull jp.icr.io/ibmtrainning/hello-world:latest
Docker Issues over Windows
Take away
$ docker run -d -p 80:80 docker/getting-started
Next