[root@ip-172-31-6-122 ~]# history
1 yum update
2 yum install docker
3 systemctl start docker
4 docker ps
5 systemctl status docker
6 docker run -d nginx
7 docker ps
8 docker run -d --name myweb nginx
9 docker ps
10 docker container ls
11 docker images
12 docker pull httpd
13 docker images
14 docker ps
15 history
Docker is a set of platforms as a
service (PaaS) products that use the Operating system level visualization to
deliver software in packages called containers. Containers are isolated from
one another and bundle their own software, libraries, and configuration files;
they can communicate with each other through well-defined channels
Docker V/S VM:
Docker Architecture:
Docker Engine
It is the core part of the whole
Docker system. Docker Engine is an application which follows client-server architecture. It is installed on the host
machine. There are three components in the Docker Engine:
- Server: It is the docker daemon
called dockerd. It can create and
manage docker images. Containers, networks, etc.
- Rest API: It is used to instruct
docker daemon what to do.
- Command Line Interface (CLI): It is a client which is
used to enter docker commands.
Docker Client
Docker users can interact with Docker
through a client. When any docker commands runs, the client sends them to
dockerd daemon, which carries them out. Docker API is used by Docker commands.
Docker client can communicate with more than one daemon.
Docker Registries
It is the location where the Docker
images are stored. It can be a public docker registry or a private docker
registry. Docker Hub is the default place of docker images, its stores’ public
registry. You can also create and run your own private registry.
When you execute docker pull or
docker run commands, the required docker image is pulled from the configured
registry. When you execute docker push command, the docker image is stored on
the configured registry.
Docker Objects
When you are working with Docker, you
use images, containers, volumes, networks; all these are Docker objects.
Images
Docker images are read-only templates
with instructions to create a docker container. Docker image can be pulled from
a Docker hub and used as it is, or you can add additional instructions to the
base image and create a new and modified docker image. You can create your own
docker images also using a dockerfile.
Create a dockerfile with all the instructions to create a container and run it;
it will create your custom docker image.
Docker image has a base layer which
is read-only, and the top layer can be written. When you edit a dockerfile and
rebuild it, only the modified part is rebuilt in the top layer.
Containers
After you run a docker image, it
creates a docker container. All the applications and their environment run
inside this container. You can use Docker API or CLI to start, stop, delete a
docker container.
Below is a sample command to run a
ubuntu docker container:
docker
run -i -t ubuntu /bin/bash
Volumes
The persisting data generated by
docker and used by Docker containers are stored in Volumes. They are completely
managed by docker through docker CLI or Docker API. Volumes work on both
Windows and Linux containers. Rather than persisting data in a container’s
writable layer, it is always a good option to use volumes for it. Volume’s
content exists outside the lifecycle of a container, so using volume does not
increase the size of a container.
You can use -v or –mount flag to
start a container with a volume. In this sample command, you are using
geekvolume volume with geekflare container.
docker
run -d --name geekflare -v geekvolume:/app nginx:latest
Networks
Docker networking is a passage
through which all the isolated container communicate. There are mainly five
network drivers in docker:
- Bridge: It is the default network
driver for a container. You use this network when your application is
running on standalone containers, i.e. multiple containers communicating
with same docker host.
- Host: This driver removes the
network isolation between docker containers and docker host. It is used
when you don’t need any network isolation between host and container.
- Overlay: This network enables swarm
services to communicate with each other. It is used when the containers
are running on different Docker hosts or when swarm services are formed by
multiple applications.
- None: This driver disables all
the networking.
- macvlan: This driver assigns mac
address to containers to make them look like physical devices. The traffic
is routed between containers through their mac addresses. This network is
used when you want the containers to look like a physical device, for
example, while migrating a VM setup
Install Docker:
Create EC2 instance:
Login on ec2 instance as a root.
Execute below command:
#yum update -y
#yum install docker
#systemctl start docker
#systemctl status docker
No comments:
Post a Comment