1. Home
  2. Docker
  3. What is Docker and why should I use it?

What is Docker and why should I use it?

If you’ve heard the terms containerisation and Docker but aren’t sure how it can help you or your developers, read on for a quick explanation!

In short, Docker is free and open-source software that lets you run multiple web applications on the same server easily, securely and consistently. You get a controlled environment that lets you & your developers feel confident that your websites will work as you expect.

What’s the difference between servers and containers?

Servers

If you’re reading this page, you’re likely running your apps and databases directly on your server’s operating system (OS), such as Debian or Ubuntu. Everything is on a single server, sharing the same version of PHP and MySQL.

Everything is closely tied together, which can cause problems:

  • An OS software update on your server might break all of your websites.
  • There’s little isolation between your websites. A problem or security breach with one can affect them all! You could run each website on its own server, but that gets expensive.
  • If you’ve got several web apps that need different versions of PHP or MySQL, it can be messy to do that on one server.
  • If you’ve had your server for years, it might be difficult to remember how it was all put together. If the server broke, how easy would it be to get it up and running again from scratch?

Containers

Docker solves those problems nicely by letting you run your apps and databases separated into neat and tidy boxes called containers that can all run on the same server:

  • Inside a container, you run something called an image which is a combination of OS, software and libraries of your choosing. In one container you might run an image with Debian 9 and PHP 7, while in another you might run Ubuntu 16.04 and PHP 5.
  • Containers are isolated from each other and from your server, which improves stability and security. (You can let specific containers talk to each other if needed.)
  • You & your developers can package up your application into an image with all the pieces it needs to work. You can run that image in a container on any server knowing that it is guaranteed to work in exactly the same way.
  • Every image has its own step-by-step recipe of how it was made (known as a Dockerfile). It’s impossible to forget how everything was configured!
  • Containers sound a lot like virtual machines, but they are significantly faster and use less RAM and disk space, helping you to save money.

Docker itself is something you install on your server. Once it’s running it gives you access to the registry of images available on Docker Hub. You can run any of those images as containers, and as many containers as you want.

What’s the difference between an image and a container?

If you download an image to your server, such as version 5.7 of the Official MySQL image on Docker Hub, you can’t change the image but you can run it in a container.

Wouldn’t everyone who runs this image have the same MySQL root password?

Fortunately, when you run an image in a container you can pass it some settings. The MySQL image lets you set the root password by passing in an environment variable.

A container is essentially your own running instance of an image, usually with some customized settings suited to your needs.

If you’re a developer, you can design your own image. You don’t have to publish your image to the Docker Hub, so you can keep the software you’ve built private.

How do I get started with Docker?

Sign up for a 7-day free trial and have a go at our WordPress Docker tutorial.

Updated on November 7, 2018

Was this article helpful?

Related Articles