DEV Community

Cover image for Docker for Dummies (Part 1)
Vignesh Pb
Vignesh Pb

Posted on

3 3 3 3 3

Docker for Dummies (Part 1)

In this post we will be taking a look at Docker from the perspective of a complete beginner and how to use it.

This post is Part 1 of a multi-part series with each part discussing a different component or a component with an additional layer of depth.

Note: This blog is deliberately meant to be simple and easy to understand and as such some topics will not be covered or will be covered in a later part when you are ready to work with them

What is Docker?

Docker is a piece of software that is used to manage (create/run/delete) containers. A container is an enclosed space where our software can run without other software interfering with it.

When do I use Docker?

Here are some situations where docker would be useful for you.

Example Situation 1: Managing different Software Versions
Say you have two websites which require the following software versions to run

  • Website 1 - PHP 8.1 and MySQL 5.7
  • Website 2 - PHP 7.2 and MySQL 8.0

To make these websites work, you need to ensure each uses the correct PHP and MySQL versions. This can be tricky, especially if you need to run multiple versions simultaneously

If you are like me then doing this could be annoying and difficult because whenever you try to meddle with your PHP/MySQL installation it breaks causing you to spend time fixing it all day

Example Situation 2: Managing consistency between team members
Say you are working on a piece of software that needs Redis version 5.0.5 and once you finish building your software you push it to Github.

Now your colleague pulls the code and runs it but it breaks because they are running Redis version 5.0.4

A small version change broke your software and you as a developer get frustrated because your complaint is "But it worked in my computer"

In both of the above situations, Docker is a great solution that solves the problem

How does the Docker Software Work?

The docker software runs like a client-server software. The server runs a process called dockerd (Docker Daemon) which the users can interact with with a CLI (Command Line Interface) or the Docker UI (User Interface)

Image description

Note: If you do not know what REST API is, don't worry about it too much for now. As long as you understand that dockerd is the program that runs your commands you should be good to go

What is the Workflow?

Using the Docker engine is very simple, the workflow is shown below

Image description

The steps are as follows

  • You create a dockerfile which contains instructions of what software you need and what you want to do with it
  • You give it to the Docker Software and ask it to create an image which is like a blueprint of the requirements for your project (eg PHP 8.1 and MySQL 5.7)
  • Once you have the image you can then give it again to the Docker Software and create a container with the specific versions of the software that you wanted.

When you create an image you can share it with your fellow developers by uploading the image to websites called as registries. These registries can be specific to a company to be shared between team members but there are also registries that the general public uses and shares images publicly.

Some common registries are

  • Dockerhub
  • Amazon Elastic Container Registry
  • Google Container Registry
  • Azure Container Registry

Summary

So far in this blog post, we saw the answers to the following questions

  • What is Docker? - A tool to manage containers
  • What problems does it solve? - Gives an enclosed space to run your software without interference from other software
  • How does the Docker software operate ? - A client server model, where the client is either the cli or the docker ui
  • What does a typical workflow look like? - You create a file and then create an image and then start the container

Terminology Recap

Here are a list of new terms that you guys would have seen in this blog post.

  • Containers
  • Images
  • Docker
  • Registries

Some homework for you

To ensure that you learn better here are some questions from me that you can ask yourself to strengthen your knowledge on docker

  • Is docker the only software that helps in containerization? Does the docker company have competitors? If so who are they?
  • What are some other registry websites? Which are the most popular ones? What registries do companies prefer? What registries do hobby developers prefer?
  • Go to a registry website and browse it once to see what is inside it.
  • Why do we need to create an image first and then a container? Why not create a container directly from the dockerfile?

It is okay if you do not find the answers to these questions right away, the best way to learn is to sit with these questions and refer online resources and slowly learn :)

Next Steps

In the next blog post we will actually run docker commands to create images, containers and will experiment with different scenarios

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay