Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views3 pages

Docker Notes

Provides the basic understanding of the docker and its functionalities. Drafted for a beginner to start from scratch.

Uploaded by

Satish Kushwah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Docker Notes

Provides the basic understanding of the docker and its functionalities. Drafted for a beginner to start from scratch.

Uploaded by

Satish Kushwah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

What is Docker?

 We can imagine Docker as a Cargo Ship that can hold big boxes (containers) having their
distinct objectives and id.
 These containers contain items (Application + Dependencies) that are required to make
that container useful and runnable anywhere.
 These items are manufactured using templates (Docker File).
 Docker is a containerization platform which packages your application and all its
dependencies together in the form of containers to ensure that your application works
seamlessly in any environment, be it development, test or production.
 Hence a container contains complete ecosystem of your application.
 Including the application and all its dependencies, and everything that is needed for an
application to run on the server.
 This guarantees that the software will always run the same, regardless of its
environment.

What is Docker file?


 This text file provides a set of instructions to build a Docker image, including the
operating system, languages, environment variables, file locations, network ports, and
any other components it needs to run.
 Each time command is run in Docker file, a new layer is created on top of the previous
layers. This allows Docker images to be built incrementally, with each layer representing
a separate instruction in the Docker file. It also allows Docker to reuse layers between
images, which can help reduce the size of images and improve build times.
 For example, if you specify a command to install a package in your Docker file, a new
layer will be created that includes the package and its dependencies. If you make
another change, such as adding a file to the image, another layer will be created on top
of the previous one.
DockerFile:
FROM openjdk:17-alpine
WORKDIR /opt
ENV PORT 8080
EXPOSE 8080
COPY target/*.jar /opt/app.jar
ENTRYPOINT exec java $JAVA_OPTS -jar app.jar
What is Docker Image?
 Docker-images are a read-only binary template (like snapshots) used to build
containers. Images also contain metadata that describe the container’s capabilities and
needs.
 Create a docker image using the docker build command whenever you pass a Docker
file to the docker build command then the docker daemon will create a docker image
according to the Docker file instruction.
 Docker images can’t be executed by themselves and cannot run or start. It is just a
blueprint for creating Docker containers.
 Run the docker images using the docker run command. Whenever we pass the
command to docker client then the docker client passes this command to the docker
daemon then docker daemon will create the container for that image.
 Push the docker image to the public registry like DockerHub using the docker push
command after pushed you can access these images from anywhere using the docker
pull command.

What is Docker Container?


 A container is a runnable instance of an image. You can create, start, stop, move, or
delete a container using the Docker API or CLI.
 Containers provide you with a lightweight and platform-independent way of
running your applications. Every container is isolated but access to resources on
another host or container can be allowed with the help of docker networking.
 A container is volatile it means whenever you remove or kill the container then all its
data will be lost from it. If you want to persist the container data use the docker
storage concept.
 Containers only have access to resources that are defined in the image, unless
additional access is defined when building the image into a container
 All the docker images become docker containers when they run on Docker Engine.

What is Docker Hub?


 Docker images are stored in a registry, which is a centralize location for storing and
distributing Docker images.
 When you run a Docker container, Docker pulls the image from the registry and runs it
on your local machine.
 Several public registries are available, such as Docker Hub, the default registry for
Docker. You can also set up your private registry if you want to store and manage images
internally.
 Docker hub is a cloud-based registry service that allows you to link to code
repositories, build your images and test them, store manually pushed images, and link to
the Docker cloud so you can deploy images to your hosts. It provides a centralized
resource for container image discovery, distribution and change management, user and
team collaboration, and workflow automation throughout the development pipeline.
 https://hub.docker.com/

Did you use Docker in your Project? If yes, why?


 Yeah, we did. We had a common problem of Developers saying “BUT IT WORKS ON MY
MACHINE”
 There are some scenarios which motivated us to move to dockerized application
 We sometimes faced issue that our same code base when deployed to test, dev, worked
fine but breaks on prod or QA servers. We found that even though code base is same but
dependencies/their version were problematic hence if we can package everything in
one big container and run application in that container with same configuration,
dependency then things won’t break abruptly. Hence, we moved to Docker.
 Apart from that we achieved few more advantages like –
o Docker is an open platform for developing, shipping, and running applications.

o Docker enables you to separate your applications form your infrastructure so you
can deliver software quickly.
o With Docker, you can manage your infrastructure in the same ways you manage
your applications.
 By taking advantage of Docker’s methodologies for shipping, testing, and deploying code
quickly, you can significantly reduce the delay between writing code and running it in
production.
 User cases involve –
o Environment standardization

o Faster configuration with consistency

 Better disaster recovery – Disaster is unpredictable. However, you can back up a Docker
image (also called “snapshot”) for the state of the container at that back-up moment and
retrieve it later when serious issues happen. For example, a hardware failure just
happened, and you need to switch your work to a new hardware. With Docker, you can
easily replicate the file to the new hardware.
 Sometimes we found a bug when deploying a new version of one software. We can
revert to the last version with the previous Docker image easily. Without Docker, we
have to set up the rollback step from runtime to runtime.
 Improvement in adoption of DevOps.

You might also like