Containers Shyam
Containers Shyam
● What is a Container?
● Containerization vs. Virtual Machine
● Docker Installation
● Main Docker Commands
● Building your own Containerized Image for Flask Application
Applications are transforming
Application Modernization
● It can automatically
allocate resources to the
nodes that are free and
saves much time
What is a container
Mongo
Node js Mongo
Express Node js
Express
● Installation process was different
● OS environment.
Developer Developer
After Containers
Container Registry
Private Repositories
https://www.docker.com/
https://hub.docker.com/
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.
● Light-weight
● Applications run in isolation
● Occupies less space
● Easily portable and highly secure
● Short boot-up time
Docker architecture
Docker Installation
● Docker currently separates its product lines into two segments.
○ Community Edition (CE), which is closed-source yet completely free, and
○ Enterprise Edition (EE), which is also closed-source and needs to be licensed on a yearly
basis
● If you are using macOS or have Windows 10 Professional installed on your laptop, it is
recommended that you install Docker for Desktop.
● Docker for Desktop doesn’t support linux. You need to install it differently.
Steps to install Docker
1. No matter what OS you're using, navigate to the Docker start page at
https://www.docker.com/get-started.
2. On the right-hand side of the loaded page, you'll find a big blue button saying Download
Desktop and Take a Tutorial. Click this button and follow the instructions.
3. You will be redirected to Docker Hub. If you don't have an account on Docker Hub yet, then
create one. It is absolutely free, but you need an account to download the software.
Otherwise, just log in.Once you're logged in, look out for the below image on the page:
Steps to install Docker
1. Click the blue Download Docker Desktop button
2. Note that if you're on a Windows PC, the blue button will say Download Docker Desktop for
Windows instead.
3. Once you have successfully installed Docker for Desktop for macOS, please open a Terminal
window and execute the following command to check whether Docker is properly installed or
not:
$ docker version
Docker main commands
● To create and a run a demo docker container in your system. Type the below
commands.
$ docker container run alpine echo "Hello World"
$ docker run -d -p 80:80 docker/getting-started
● This command contains multiple parts. First and foremost, we have the word
docker.
● This is the name of the Docker Command-Line Interface (CLI) tool, which we are
using to interact with the Docker engine that is responsible to run containers.
● Next, we have the word container, which indicates the context we are working
with. As we want to run a container, our context is the word container.
● Next is the actual command we want to execute in the given context, which is run.
Starting and Stopping Containers
● A container can be started again using the docker container start command
● Now, instead of using the container name, we can use the CONTAINER_ID in our
expression:
$ docker container ls
● Containers are runtime instances of an image and have a lot of associated data that
characterizes their behavior.
● To get more information about a specific container, we can use the inspect command
FROM python:3.6
WORKDIR /app
ADD . /app
COPY requirements.txt /app
RUN python3 -m pip install -r requirements.txt
RUN python3 -m pip install ibm_db
RUN python3 -m pip install requests
EXPOSE 8080
CMD ["python","app.py"]
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>