DEV Community

Cover image for Introduction To Docker!
MilburnGomes
MilburnGomes

Posted on

Introduction To Docker!

Happy New Year 2020!

This article is for beginners only. Specially for those who have never used Docker or want to get the hang and feel of Docker. Hence this is a very basic tutorial. In my further posts I will be covering more practical projects.

So what is Docker?
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. (Source: Wikipedia)

In order to use Docker, you need to create an account. While creating your account, you will be asked to create your Docker ID. Hence this docker ID will be used in future such as to login in Docker Hub, to identify your Repository, upload to your repository etc.

Once your account has been created, you will need to download the Docker software called as 'Docker Desktop' on your system.

So let's get started!

I've just begun using Docker and as I discover, I will upload more articles on the same. This article I've found on the Docker site and followed their step by step procedure and I was able to achieve the result. Following is the same URL for the Quick Start Tutorial

Step 1: Download
Let's get you started: you will need to download and install Docker to use the Docker command line interface (CLI).

Docker Desktop
The preferred choice for millions of developers that are building containerized applications

Download Docker Desktop for Windows or Mac

Step 2: Clone
First, open a Mac terminal or Windows PowerShell and download a fun example.
This repository contains everything you need to create your first container.

git clone https://github.com/docker/doodle.git
(Requires Git)

Step 3: Build
Now let's build and tag a Docker image.
A Docker image is a private filesystem, just for your container. It provides all the files and code your container will need. Running the docker build command creates a Docker image using the Dockerfile. This built image is in your machine's local Docker image registry.

cd doodle/cheers2019 && docker build -t <docker_id>/cheers2019 .

Replace <docker_id> with your Docker ID which you have entered while creating Docker Account.

Step 4: Run
Great! Now let's run your first container.
Running a container launches your software with private resources, securely isolated from the rest of your machine.

docker run -it --rm <docker_id>/cheers2019

You should be able to see the output as below:
Docker Output

Step 5: Ship
Share your image on Docker Hub
Once you're ready to share your container with the world, push the image that describes it to Docker Hub.

docker login && docker push <docker_id>/cheers2019

If everything up to here is done correctly, then

Congratulations

At this point, you have successfully set up Docker Desktop and Docker Hub. You have built, run and shipped your first container. Carry on to master all the power of the Docker platform.

Thanks for reading.
Cheers!

Top comments (1)

Collapse
 
nicolaerario profile image
Nicola Erario

For Linux I can suggest to replace docker with podman: rootless, daemonless and CgroupsV2 compliant. Ah, same syntax