Overview
I recently started learning docker and it was interesting. Docker uses client-server (docker-engine) architecture, it has its client components that talks to a server component using a restful API. A container is a special process running on your computer, all containers on a host share the operating system of the host.
Prerequisites
- Docker CLI and Desktop Installed.
- Node.js v22.14.0
- Git
Setup Instructions
- First, I wrote a simple application using node.js in
app.js
file
- I dockerized the application, meaning I made a small change so that it can be run by docker by adding a simple dockerfile.
A dockerfile is a plain text file that includes instructions that docker uses to package up this application into an image.
- To build the docker image, run the command
docker build -t hello-docker
- To run this image to on any computer running docker
docker run hello-docker
- Once we have the image; we can push it to DockerHub. DockerHub to docker is like GitHub to Git. It is a storage for docker images that anyone can use. The image must be tagged before pushing.
docker tag <image-id> <dockerhub-username>/<repository-name>:<tag>
- Then push
docker push amehmathias/hello-docker:latest
- Once our application image is on DockerHub, then we can put it on any machine running docker.
Challenge faced
I encountered an error while trying to push my application image to DockerHub without first tagging it
Based on the error message on the terminal, I noticed I have to tag my image before pushing it.
Top comments (2)
Great post, really! We’ve had similar experiences with Docker. One thing we always emphasize is the importance of version control for Docker images, especially when working in multiple environments. It really helps to avoid unexpected issues during deployment. Also, tagging images before pushing them to DockerHub is something that can easily slip through the cracks, a mistake we’ve made too. Thanks for sharing your journey and insights, it’s always helpful to see how others tackle common challenges. Keep it up)
Thank you for your insight.