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

My Docker Learning Journey

The document outlines a personal learning journey into Docker, highlighting its benefits such as lightweight, portability, fast deployment, and scalability. It explains the purpose of Dockerfiles, provides common instructions, and walks through creating a simple Dockerfile for a Node.js application. Additionally, it covers building and running Docker containers, useful commands, and future learning goals including Docker Compose and Kubernetes.

Uploaded by

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

My Docker Learning Journey

The document outlines a personal learning journey into Docker, highlighting its benefits such as lightweight, portability, fast deployment, and scalability. It explains the purpose of Dockerfiles, provides common instructions, and walks through creating a simple Dockerfile for a Node.js application. Additionally, it covers building and running Docker containers, useful commands, and future learning goals including Docker Compose and Kubernetes.

Uploaded by

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

🚀 My Docker Learning Journey

I have started my journey into Docker, one of the most exciting tools in the DevOps world. Today,
I explored Dockerfiles, containers, and how Docker helps in building, shipping, and running
applications efficiently.

📌 What is Docker?
Docker is a platform that allows developers to package applications and their dependencies
into containers. These containers ensure that the app runs the same, regardless of where it's
deployed.

🔥 Why Use Docker?

✔️ Lightweight – Uses less system resources than VMs


✔️ Portable – Runs the same on any environment (local, staging, production)
✔️ Fast Deployment – Start/stop containers instantly
✔️ Scalability – Easily scale applications in the cloud

🛠️ Understanding Dockerfiles
A Dockerfile is a blueprint for building Docker images. It contains instructions that tell Docker how
to set up the environment, install dependencies, and configure the application.

📝 Common Dockerfile Instructions

Instruction Description
FROM Specifies the base image (e.g., Ubuntu, Alpine, Node.js)
RUN Executes commands inside the container
COPY Copies files from the local system to the container
CMD Defines the default command that runs when the container starts
ENTRYPOINT Similar to CMD but more flexible for passing arguments
EXPOSE Defines which ports the container will listen on
WORKDIR Sets the working directory inside the container
ENV Declares environment variables
USER Sets the user under which the container runs
ONBUILD Specifies commands that run when the image is used as a base image
🏗️ Writing a Simple Dockerfile
Let's create a Dockerfile for a simple Node.js application.

# Use an official Node.js image as the base


FROM node:18

# Set the working directory inside the container


WORKDIR /app

# Copy package.json and install dependencies


COPY package.json ./
RUN npm install

# Copy the rest of the application files


COPY . .

# Expose the application on port 3000


EXPOSE 3000

# Default command to run the app


CMD ["node", "server.js"]

🔹 Explanation:

1️⃣ Base Image – Uses Node.js as the starting point


2️⃣ WORKDIR – All commands run inside /app
3️⃣ COPY – Moves required files inside the container
4️⃣ RUN – Installs Node.js dependencies
5️⃣ EXPOSE – Opens port 3000 for the app
6️⃣ CMD – Runs server.js when the container starts

🏃 Running Docker Containers


Now, let's build and run our container.

🔹 Step 1: Build the Docker Image


docker build -t my-node-app.
This command creates a Docker image named my-node-app.

🔹 Step 2: Run the Container


docker run -d -p 3000:3000 my-node-app
This command runs the container in detached mode (-d) and maps port 3000 of the container to
port 3000 on the host.
🔹 Step 3: Check Running Containers
docker ps
This shows all running containers. If you need to stop it, use:

docker stop <container_id>

🛠️ Useful Docker Commands


Command Description
docker images Lists all Docker images
docker ps -a Shows all containers (including stopped ones)
docker logs <container_id> Displays logs from a container
docker exec -it <container_id> bash Opens a shell inside the running container
docker rm <container_id> Removes a stopped container
docker rmi <image_id> Deletes an image

🚀 Next Steps in My Docker Learning


I’m still at the beginning of my Docker journey, but I’ve already learned a lot about:
✅ How Docker simplifies development & deployment
✅ Writing Dockerfiles and creating images
✅ Running, stopping, and managing containers

🎯 My Next Goals:

🔹 Learn Docker Compose for multi-container applications


🔹 Work with Docker Volumes for persistent storage
🔹 Deploy containers using Kubernetes

If you have any tips, resources, or experiences with Docker, feel free to share them in the
comments! Let’s grow together. 🚀

You might also like