In Docker, there are three fundamental concepts that are important to understand: Container
, Image
, and Dockerfile
.
Container
It is the primary component in Docker. A container is an isolated execution environment that contains an application and its related components.
Each container in Docker operates like a small virtual machine, encapsulating everything needed to run the application, including libraries, dependencies, and configuration.
Container allow you to run applications consistently across different environments without worrying about interactions between different applications.
You can create, run, stop, and delete container as needed.
Image
It is a lightweight, packaged set of files that includes everything needed to create a container
. An image
can be seen as a blueprint for creating container. It contains application configurations, source code, libraries, and executable files.
Image are immutable, and each container created from an image will have its own separate and isolated state from other container.
You can create, view, and share image
as needed.
Dockerfile
It is a simple text file that contains instructions for building a Docker image
. The Dockerfile defines the steps and processes to create an image
from specific components and configurations.
By using a Dockerfile, you can automate the image
building process, ensuring consistency and easy reproducibility of image across different environments.
Dockerfile contains instructions such as FROM (specifying the base image
), RUN (executing commands during the build process), COPY (copying files into the image
), and CMD (defining the default command when the container
runs).
Dockerfile helps you create custom image
and manage the image
building process flexibly.
These concepts are the core of Docker and enable you to package, deploy, and manage applications easily and consistently. By using Container
, Image
, and Dockerfile
, you can leverage the flexibility and capabilities of Docker in the development and deployment process.