What is Docker ?
Docker is an open source platform that enables developers to build, deploy, run, update and manage containers. Containers allow a developer to package up a application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.
Why use Docker?
- Portability: Docker containers run without modification across any desktop, data center and cloud environment.
- Lighter weight and more granular updates: multiple processes can be combined within a single container. This makes it possible to build an application that can continue running while one of its parts is taken down for an update or repair.
- Automated container creation: Docker can automatically build a container based on application source code.
- Container versioning: Docker can track versions of a container image, roll back to previous versions, and trace who built a version and how. It can even upload only the deltas between an existing version and a new one.
- Container reuse: Existing containers can be used as base images—essentially like templates for building new containers.
- Shared container libraries: Developers can access an open-source registry containing thousands of user-contributed containers.
Docker Host:
- A Docker Host is a physical computer system or virtual machine installed with Docker.
- This can be your laptop, server, or virtual machine in your data center, or compute resource provided by a cloud provider.
- The component on the host that does the work of building and running containers is the Docker Daemon.
Docker Image:
- A Docker image is a file used to execute code in a Docker container.
- Docker images act as a set of instructions to build a Docker container, like a template.
Docker Container:
- Docker is a set of Platforms as a Service products that use OS-level virtualization to deliver software in packages called containers.
- The service has both free and premium tiers.
- It was first started in 2013 and is developed by Docker, Inc.
- A Docker Container is a way to package applications with all the necessary dependencies and configurations.
- Portable artifact, easily shared and moved around.
- Makes development and deployment more efficient.
- Docker containers are built using Docker Images.
Docker File:
- A Dockerfile is a text document file containing all of the commands and statements that define an Image.
- Docker can build images automatically by reading the instructions from a Dockerfile.
- Dockerfile is the source code of a Docker Image, so it is pushed to a SCM tool such as Git.
Explanation:-
- Line #1 – Use base Docker image Python with tag 3.8-slim buster .
- Line #3 – Creates a folder in the docker container called ‘app’.
- Line #5 – Copies the requirements.txt file to the docker container.
- Line #6 – Downloads and installs all the Python dependencies required for an application to run.
- Line #8 – Copy everything from our current directory to the WORKDIR.
- Line #10 – Starts our python application.