The main focus of the article will be the application phase of Docker,you already know what docker is and if you unaware then you can look here.
How docker is actually used in Development
Have you ever faced a situation where a project works perfectly on your system, but fails on someone else’s?
I faced this during my college project presentation. My laptop wasn’t available, so I tried running the project on a friend’s laptop. The project failed because of a Node.js version mismatch — my project used a newer version, while my friend had an older one installed. I had to manually install the correct version and fix dependencies. It was a hectic process. Later, I realized Docker would have completely solved this problem.
Developer mainly use to solve "Running in your computer but not on mine problem ".
Docker use to standardize that installation problem ,now you do not have to worry about the hefty task of installing all dependencies manually or solving version conflict in the deps.
Core Docker Concepts
Docker file - it is recipe for making Docker image.
Docker image - A packaged snapshot containing your app, dependencies, and runtime.
Docker container - it is the running state of your Docker image .
Docker Hub - it is like github for DockerImage.
Docker compose - it is file that helps to run multiple container and communicate with each other. without docker compose , you have to run each container separately. But with docker compose , you can run using single cmd.
Basic Docker Commands
Build an image
docker build -t Frontendimg:01 .
This cmd build a docker image named Frontendimg with tag of 01 from the dockerfile in current directory.
Run a container
docker run -d -p 3000:3000 --name "myrandomname" cd214912421
This cmd create the container from the given image .
--name -> this helps to give container a name.
-d -> allow terminal to work in detach mode , if not used terminal will be busy and you will not be able to use the current terminal .
-p -> port mapping hostport:containerport , in short you will be able to visit your project in https://localhost:3000.
cd214912421 -> this is image id of which you need to create a container. You can use image name in the image id place.
List Docker Image
docker image ls -a
This cmd list all image that is created by you ,-a ensure it also include the untagged image.
List container
docker ps -a
All container which is running ,exist or exited.
Stop Container
docker stop <container id or name>
This cmd is used to stop the container .
Remove Container
docker rm <container id or name>
This cmd delete the container which is stopped but still exist. it can only run if that container is not running.
Remove all stopped containers
docker container prune
This cmd will remove/delete all stopped container
Remove an image
docker rmi imagenameorimageid
This cmd will delete existing image.
Important points
- You can build multiple images for different versions of your project.
- Changing source code doesn’t require changing the Dockerfile unless dependencies change.
- You can run multiple containers from the same image on different ports.
Why Docker Matters
Docker ensures that everyone runs the project in the exact same environment, from development to production.
This makes collaboration smoother and deployment reliable — which is why Docker is widely used in DevOps and modern software teams.
Really appreciate your insight on this, tell me if I am wrong somewhere.
By Saturday ,I will post about DockerFile and DockerCompose .
Top comments (0)