A docker is a ecosystem where you can create and run containers! But why is docker so popular and everyone is talking about it?
Have you ever tried to install a game in your personal computer and faced error? What you do you go download the specified dependency and try to run it again then you face another error after googling and searching in stack overflow for quite a long time you get ready with the game. But the process becomes so exhaustive you loose all your interest to play it! I know this happens a lot.
Coming into more practical aspect of it. As developers our ultimate aim is to develop software such that people can use it. For developing a software we need a development team , a testers team , a operations team and a team who will deploy. For each and every stage the team needs to download the dependencies and run the software. Say, developing a web application with web server using node.js and express , database using MongoDB , messaging using redis and front-end with Vue.js ,downloading packages such that software runs becomes hectic because not only different modules you also need to know version of the corresponding libraries. This is real hectic! Solution to this problem is docker.
Containerizing the packages needed to run the software solves this problem. After containerizing developers can run the software with a simple docker run command. So what are containers ? Containers are completely isolated environment , similar to virtual machines expect the fact that they all share the same OS kernel. If the kernel is of Linux containers can run any version of Linux on them. Containers always run Linux on them. Even if you are running containers on Windows or Mac they run on Linux VMs. But, the concept of containers are not new they existed 10 years before but setting up those containers using low level language was a humongous task but docker provides a high level setup which helps making containers easy.
Installing docker on Ubuntu:
sudo apt install docker.iosudo systemctl enable — — now docker
Now your docker is installed test it with the following command
sudo docker run hello-world
If you are on Windows Professional or Mac you can go for docker hub. If you are on windows home you need to install a Virtual Machine and use any Linux version. Remember you only need to dockerize your files once and then you can work seamlessly.
You can run a fun container which you can run is whalesay
sudo docker run docker/whalesay cowsay Hey Readers!
For more images you can refer to here
Some of the basic docker commands are:
- docker version — checks the version of docker running
2. docker run — Runs a command in a new container.
3. docker start — Starts one or more stopped container
4. docker stop — Stops one or more running containers
5. docker ps -a — Lists out all the images running of containers running
6. docker rm <container_name> — removes the container whose name has been specified
7. docker rmi <image_name> — removes the image whose name has been specified
8. docker build — Builds an image form a Docker file
9. docker pull — Pulls an image or a repository from a registry
10. docker push — Pushes an image or a repository to a registry
11. docker export — Exports a container’s filesystem as a tar archive
12. docker exec — Runs a command in a run-time container
13. docker search — Searches the Docker Hub for images
14. docker attach — Attaches to a running container
15. docker commit — Creates a new image from a container’s changes
If your machines says restricted and doesnot have the needed permission use sudo.
There are a lot of concepts which comes in play but writing all those will extend the blog and you may be confused. For more you can refer to Docker. Happy dockerizing! 😁