Docker lifecycle
What is docker?
Docker lifecycle
What is docker?
Docker is a “open source platform” designed specifically to help developers build, share and run containers. Now what is container? Developers can package their applications and their dependencies into a box (typically a lightweight box ) called containers. In simpler terms it helps to eliminate the tedious environment configuration.
Docker Image is a read only template which contains OS base, application code, runtime environment (i.e python, java, node) libraries & dependencies and configuration files. All these are the layers in which docker reuses layers to stay fast and lightweight.
How do we build a Docker Image ?
We build docker images using Docker file. Below is the example of the docker file .
FROM python:3.11 WORKDIR /app COPY . . RUN pip install -r requirements.txt CMD [“python”, “app.py”]
Types of Docker Images
-> Official Images which are maintained by Docker or trusted vendors.
Examples: nginx, python, node, mysql, ubuntu
-> Base Images are minimal images, mostly used while building a custom systems.
Examples: ubuntu, apline, debian, scratch
-> Alpine-based Images are lightweight images ( used for cloud deployments and CI/CD pipelines.
Example: python:3.11-alpine
-> Language-specific Images is used during app development, backend services and APIs
Examples: node:18, python:3.11, openjdk:17
-> Application Images built using Dockerfile.
Example: Flask API image, React app image, monitoring tool image.
->Development image has the debugging tools and extra logs. Hot reloading to see the code changes without manually restarting the container.
->Production image are secure and light weighted.
Now lets see the Docker container Lifecycle which cover the full cycle from creation of container to removal of container. To create a container we need a Docker image which we are already aware, the docker images ( i.e layered blueprint on container creation) which we use for below example is present in the DockerHub which is a public registry. We can also pull image from private Registry like Amazon ECR and we build image on our local machine too.
Run : docker pull nignx
it pulls the image of nginx from DockerHub.
Once we have the image we can create the conatainer.
Run : docker create nginx
It creates the container.
Note: Container will run, pause, stop, destroy only if we run the commands for it.
run : docker run nginx ( to run the container )
run: docker ps ( to check the running containers)
CONTAINER ID. IMAGE. STATUS a3f9c2d8b1e7. nginx. Up 2 minutes make a note of the container ID.
Use the below commands for the remaining process in the lifecycle.
Pause and unpause states :
docker pause <container_id> & docker unpause <container_id>
Stop and Removing the Container:
docker stop <container_id> and docker rm <container_id>
DOCKER LIFECYCLE as follows:
Build Docker image → Create Docker container (using the Image ) → Start → Running → Pause → Stop → Remove.
Common Confusions:
1)Difference between Docker file and Docker image?
Docker File -> set of instructions on how to build an image.
Docker Image -> its a built package from those instructions, on a clear point we use docker file to build a docker image.
- Difference between Docker Registry and DockerHub?
A Docker Registry is the system that stores and distributes Docker images.
A Docker Hub is a specific public registry service provided by Docker.
메타데이터
- post_id
- 45a2c409a23c
- slug
- docker-lifecycle-45a2c409a23c
- url
- https://medium.com/@mbmani66/docker-lifecycle-45a2c409a23c
- canonical_url
- https://medium.com/@mbmani66/docker-lifecycle-45a2c409a23c
- author_url
- https://medium.com/@mbmani66
- status
- ok
- fetched_at
- 2026-06-23 03:48:11