Web

What is Docker? What does it do? How to use Docker?


What is Docker?


In short, Docker is a platform for quickly packaging, deploying and running software applications.


It accelerates the software development process, simplifies application deployment and increases portability across systems. It allows developers and system administrators to easily run, deploy and manage applications.

 

What does Docker do?


Now that we have given the general definition, let us examine the picture below for clarity.


 

 

When we develop a project, we install the services we need on our computer, right? Just like in the photo above. And these services we install have separate libraries and dependencies. This can cause us some problems from time to time. For example; the dependency of one service may negatively affect another service, or a different operating system may be required for one service to work more efficiently, while another service may not require a different operating system to work properly. As you can see, conflicts like this can arise between services. So how does Docker solve these problems?

 

 

What is Docker Container?


 

 

The answer to this question is actually very simple. As you can see, Docker separates each service into boxes that are isolated from each other. These boxes you see are called "Container". Containers are basically a mini operating system that contains the environment in which the application will run. They are easy, fast and less costly to build. It can be built in one place and run anywhere.

 


What are the benefits of Docker?


Certain steps are followed until a project is developed and taken live.



Some problems may arise during these steps. For example, when moving from development to testing, the tester may not have installed any libraries or may have encountered an error - such as a version difference - due to his computer. This may cause the process to be prolonged. Docker eliminates all these negativities. Since the libraries etc. required for the project are installed in the container, the tester does not need to install anything. This eliminates the expression "It was working on my computer." Thanks to Docker, all these steps continue exactly the same.

 


What is Docker Image?


It is a package that contains all the files, libraries, code and other dependencies needed to run Docker containers. Docker image is the image files of the applications or OSes that will be installed and run in the containers. For example; Ubuntu, PostgreSQL, Nodejs, Redis, MySQL, etc.

 


What is Dockerfile?


It is the file where you define the details of the image. Each command is called a layer. The commands defined here create the Image. With the Image, the Container is launched.

 


What is Docker Hub/Registry?



Docker Hub is the official repository platform where images are made available to us as public or private. It can be compared to Github for clarity. Just like github, developers upload open-source docker images and share them on DockerHub, allowing us to download and use them.


In short, images are kept in Docker Hub/Registries. For example, you want to use the mysql image; you can download it from the mysql image link with the "docker pull mysql" command and now you can create containers with this image. You can browse the Docker Image List here to review the platform and access the images.

 


 

 

What is Docker Compose?


Docker compose is an agent for defining and running complex projects. With Docker compose, multiple containers can be defined in a single file. In the file, the relevant containers are connected to each other and then with a single command, all the requirements that the application may need can be run.

 


The most used docker commands

 

  • Learn the version of Docker

docker --version


  • Image download

docker pull image_name


  • Listing images

docker images 


  • Running images

docker run image_name


  • Viewing working containers

docker ps


  • Delete container

docker rm container_id


  • Delete image

docker rmi image_id


  • Restart container

docker restart container_id


  • Stop container

docker stop container_id


  • Start container

docker start container_id


  • Forced container stop

docker kill container_id


  • Run image in background

docker run -d image_name/image_id


  • Image foreground run

docker run attach image_name/image_id


  • View container logs

docker container logs image_name/image_id


  • Opening the interactive terminal of the container

docker run -it image_name/image_id







Kaynaklar:







 



About author

ahmetselimbozz

I am a computer engineering student who loves to develop, see, research, learn, explore and also defines himself as a backend developer.


Scroll to Top