• 8 hours
  • Medium

Free online content available in this course.

course.header.alt.is_certifying

Got it!

Last updated on 8/28/24

Discover Docker

Docker was initially created to respond to the needs of a Platform as a Service (PaaS) company called DotCloud. Later down the line, in March 2013, this company created a new structure called Docker, Inc. and made its product available as open source. That product was Docker.

Docker logo
Docker logo

Docker entered the world of containers with a fresh way of thinking. In the Docker vision, a container should only run a single process. This means that in a scenario where we have a LAMP stack (Linux, Apache, MySQL, PHP), we would have to create three different containers: one for Apache, one for MySQL, and one for PHP. In an LXC or OpenVZ container, on the other hand, we’d be able to run all three services in one single container.

Understand Why we Use Docker

Docker responds to a significant problem in the development world.

Let’s take two examples: you’ve developed your Twitter Lite project locally. Everything’s working well, but when the time comes to put it into production, you realize that you don’t know how to deploy your project. Another example: you’re in a team of 10 people where everyone is using a different OS (Ubuntu, macOS, Windows, CentOS, etc.). How do you achieve a unified and functional environment for the whole development team?

Docker solves both of these problems with containers. Thanks to Docker, you’ll no longer have any issues with different environments. Your code will work everywhere!

Use Docker in All Your Environments

Docker is used by many companies in a variety of different ways. One of the key uses of Docker is creating local environments. It’s easier to use Docker locally when working with lots of different versions of software, as it means you avoid any compatibility issues between them. 

We also find Docker in the field of CI (Continuous Integration) and CD (Continuous Delivery), where it can be used to rapidly create isolated spaces for running tests.

Docker: an Improved Version of LXC

Docker started out as a layer of the LXC container, providing various changes to make containers more flexible and portable.

Docker containers also provide the possibility of stateless and immutable infrastructure.

Stateless and Immutable

Stateless vs. Stateful

In the world of Docker, you’ll frequently come across the words “stateless” and “stateful,” which are two different categories of containers. It’s important to know what each category is.

A MySQL database, for example, would be stateful as it stores a state. So, if you shut down and then restart your database, you’ll find it in the same state of operation.

Stateless is the opposite: the application does not store state. HTTP, for example, is stateless. For each new HTTP request, the same series of actions will be carried out.

A Container is Immutable

A container’s immutability is also important. A container should not store data that you need to be preserved, as it will lose it (unless you’ve persisted your data). If you do want to locally put a database in a Docker container, you need to create a volume to store your data so that it is persisted.

Select the Right Version of Docker

There are two different versions of Docker distributed by Docker, Inc.:

  • Docker Desktop (Mac, Windows or Linux)

  • Docker Community Edition (Linux only)

Docker Desktop can be installed on Windows, macOS and Linux and is available via a free (Personal) or different paid Docker subscriptions (Pro, Team or Business) depending on your environment.

A comparison of the different subscriptions available is outlined here.

If you use Linux, use the Community Edition (CE). You’ll also use this version for your servers.

Let’s Recap!

In this chapter, you’ve been introduced to Docker and what sets it apart from other containers:

  • Docker containers are different from Linux containers (LXC) as they are—by definition—immutable and stateless.

  • Docker is used at all infrastructure levels (CI, Development, and Production).

  • There are a number of differences between the available versions of Docker—Free (Personal) and paid for (Pro, Team and Business).

In the next chapter, you’ll install Docker on your own workstation!

Example of certificate of achievement
Example of certificate of achievement