Docker — Basic Actions and Installation s— Tutorial 1

Gal Hever
3 min readJan 9, 2022

Intro to Dockers

Docker is a software platform that allows you to build, share and run applications in containers.

Docker enables to work with some application without any installation. To better understand why you need such a platform, let's say that you want to compare between few softwares or databases, Docker enables you to do it easily without installations which can save of time and effort.

It can be also necessary if you built a system for the customer that you want to upgrade its version and maintain the previous version for other customers that are still working with the previous platform. Upgrading the service, packages and DBs can cause to collisions with the previous version that you want can avoid if you use Docker.

What is an Image?

Image is a package that includes all the infrastructures an application needs for running, such as: code, directories, settings, environment variables and so on. The image is saved on your computer and you can create many container of each image.

What is a Container?

A container is an activation of a particular image. The connection between the two is similar to a "file" and a “process". The image represents a file on the disk, and when you run the image you get a "process" in memory. That's why the command that shows all the containers currently running on your computer is:
docker ps

In order to start producing containers, first we need to install Docker on our computer.

Installation

You can select an installation according to your operating system from this page:

https://hub.docker.com/search/?type=edition&offering=community

To make sure everything was downloaded properly, go to CMD or Terminal and write:

docker --version

or

docker info

Pull an Image from DockerHub

Docker can download the image and create a new container by the command docker run . If you try to run an image that you didn’t download before Docker will automatically try to find if there is a version of it in the Dockers official repository DockerHub. Let’s try to pull our first Docker that just prints “Hello World” to the screen. Open CMD and write the next command:

docker run hello-world

Now, let’s check which images we have on our computer:

docker image ls

To check which containers you have on your computer you can use:

docker container ls -a

You can activate as many containers as you want for each image. If you delete the -a from the command you will see just the active containers.

You can activate a non-active container by the command:

docker start -a <Container ID>

If you want to run an active container and to manage to work inside the container environment use this line:

docker container run -it <image_id> /bin/bash

Remove or Stop

You can stop the container by:

docker stop <Container ID>

Or remove the container completely by:

docker rm <Container ID>

Or remove the image from your computer by:

docker rmi <Image Name>

End Notes

In this tutorial we went over the basic actions of Dockers. I hope this tutorial helped you to better understand why Dockers are helpful:) If you wish to learn how to create your own image I recommend you to continue to the next tutorial — Docker s— Build your first Image — Tutorial 2.

--

--