Hi everyone ,I am a Arthur and in this article I want to talk about some Docker things that are easy to miss when you are just starting with containers.
Docker is not only about writing a Dockerfile and running docker build.
Once you start using Docker for real projects, small things can create big problems.
Your image can become too large.
Your container can use more memory than expected.
Your app can work locally but fail after deployment.
So here are some practical Docker lessons that are worth knowing.
1. Your Docker Image Can Become Very Large
One common mistake is copying everything into the image.
For example:
COPY . .
This can also copy files you do not need, such as:
node_modules.git- log files
- local configuration
- temporary files
A simple .dockerignore file can help:
node_modules
.git
.env
*.log
This makes the build cleaner and can also reduce the image size.
A smaller image usually means less data to transfer and faster image pulls during deployment.
2. Do Not Put Secrets Inside the Image
This is an important one.
You should not put things like database passwords or API keys directly inside your Dockerfile.
For example, avoid doing this:
ENV DATABASE_PASSWORD=my-secret-password
Why?
Because image layers can keep information that you thought you removed later.
Use environment variables or a proper secrets system instead.
For local development, you might use:
DATABASE_URL=your_database_url
For production, use the secret management system provided by your platform.
3. Your Container Is Not Your Server
This is something new Docker users often misunderstand.
A container is meant to run your application.
It is not normally a replacement for the whole server.
For example:
Server
↓
Docker
↓
Container
↓
Your Application
The server provides the CPU, RAM, storage, and network.
Docker creates an isolated environment where your application runs.
This difference becomes important when you deploy multiple applications on the same machine.
4. Containers Can Use Too Much Memory
Docker does not magically make an application lightweight.
If your Node.js application has a memory problem, putting it inside Docker will not fix the problem.
You can set resource limits when needed.
For example:
docker run --memory=512m my-node-app
Now the container has a memory limit.
This is useful on shared servers because one application should not be allowed to consume all available memory.
5. Use a Small Base Image
Your base image matters.
For example:
FROM node:24
can be much larger than:
FROM node:24-alpine
A smaller image can reduce storage and download time.
But do not blindly choose the smallest image.
Some packages need system libraries that may not be available in a minimal image.
So the better rule is:
Use a small image, but make sure your application actually works with it.
6. Build Layers Can Make Your Builds Faster
Look at this:
COPY package*.json ./
RUN npm install
COPY . .
This order is useful.
Docker can reuse previous build layers when the files have not changed.
If you change only your application code, Docker may not need to install all your packages again.
That can make development builds much faster.
This is a small Docker detail, but it makes a big difference when you build images many times every day.
7. Do Not Store Application Data Inside the Container
Containers can be removed and recreated.
So if your application writes important data inside the container filesystem, you can lose it when the container is replaced.
For example, databases should normally use persistent storage.
The same idea applies to uploaded files.
Use volumes or external storage when data needs to survive container changes.
Think about it this way:
Container = temporary
Persistent storage = data that must stay
This is especially important when moving from local development to production.
8. Health Checks Matter
Your container being "running" does not always mean your application is working.
A process can still exist while the application is unhealthy.
A health check can help detect this.
For example:
HEALTHCHECK CMD curl --fail http://localhost:3000/ || exit 1
Now the system can check whether the application is actually responding.
This becomes useful when you later use Docker Compose, Kubernetes, or a load balancer.
9. Why Developers Use a VPS for Docker
When you want to move from local development to a real server, you need somewhere to run your containers.
A VPS (Virtual Private Server) gives you a private virtual machine with allocated resources such as CPU, RAM, storage, and network access.
That makes it useful for developers who want more control than basic shared hosting.
For example, you can rent a VPS and install Docker on it.
Then your deployment can look like:
GitHub
↓
Docker Build
↓
Docker Image
↓
VPS
↓
Docker Container
↓
Your App
This is also a good way to learn real deployment.
You can manage the server, configure a firewall, connect a domain, add HTTPS, run Docker containers, check logs, and monitor CPU and RAM.
The important part is that you are working with a real environment instead of only running code on your laptop.
10. Docker Is Only One Part of Deployment
This is probably the biggest thing to understand.
Docker solves the application environment problem.
It does not automatically solve:
- HTTPS
- DNS
- Backups
- Monitoring
- Server security
- Database management
- Scaling
- Deployment automation
A real production setup may look more like this:
Developer
↓
GitHub
↓
CI/CD
↓
Docker Image
↓
VPS / Cloud
↓
Nginx
↓
Docker Container
↓
Application
↓
Database
Each part has a different job.
Once you understand this, Docker starts making much more sense.
A Simple Docker Workflow for Developers
For a small project, you can start with:
Write Code
↓
Test Locally
↓
Build Docker Image
↓
Run Container
↓
Push Code
↓
Deploy
↓
Monitor
Later, you can add GitHub Actions, automated testing, image scanning, a container registry, and automatic deployment.
You do not need all of these on day one.
The Main Lesson
Docker is not just a skill where you learn five commands and put "Docker" on your resume.
The useful skill is understanding why containers behave the way they do.
Know what happens to your files.
Know where your data lives.
Know how much memory your application uses.
Know how your image is built.
Know how secrets are handled.
And most importantly, know what happens when that container reaches a real server.
That is when Docker becomes a real developer skill instead of just another tool to learn.
Final Thought
If you are learning Docker, don't spend all your time watching tutorials.
Take one application you already have.
Put it inside a container.
Make the image smaller.
Add a health check.
Handle your environment variables properly.
Deploy it to a real VPS.
Then break something and fix it.
You will probably learn more from that one project than from another ten hours of tutorials.
Top comments (0)