blog-image

May 01, 2019

14 min read

Getting Started With Docker On Your VPS (Tutorial)

Written by

Vippy The VPS

Getting started with Docker on your VPS is pretty straightforward, and once you're set up via this Docker tutorial, it's like you've "leveled up" in DevOps.

Why get started with Docker on your VPS?

Docker is a platform for designing, building, and launching "containers," which are isolated environments containing all the software and configuration files necessary to run a service or application.

Running Docker on your virtual server gives you more stability, more flexibility, and a lot more ways to recover quickly if (or when) you mess things up.

Installing Docker on your machine brings significant benefits:

  • You can develop locally using a specific environment.
  • You can ensure that local development environment is replicated exactly when you're ready to deploy code, ensuring 100% compatibility.
  • Build Dockerfiles/Docker images to make your site/app portable to multiple VPSs for redundancy or fail-over.
  • Host multiple applications on a single VPS without them interacting—or conflict—with one another. For example, run two Wordpress installations with separate Apache/Nginx web servers and separate MySQL databases.
  • One container can crash without affecting other containers or the health of your VPS.
  • Capability to automatically restart containers upon reboot of the VPS itself.
  • A certain degree of improved security by separating different apps into different containers.
  • Easy backups!

It's clear that Docker should probably have a role on your VPS.Let's get started on installing Docker and taking the first steps toward a container-powered VPS.

[cta_inline]

Prerequisites for this getting started with Docker tutorial

  • A virtual private server (VPS) running any of our available OS options. See our pricing for details.
  • A non-root user account (commands requiring escalated privileges will use sudo).

Step 1. Installing Docker

You can get started with Docker by following [the official guide for your Operating System](https://docs.docker.com/engine/install/).

Step 2. Testing your Docker installation

The people behind Docker recommend testing out your Docker installation with a basic Hello world command to ensure everything is working the way it should. If so, you'll see the following output:

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Step 3. Some post-installation configurations

Now that Docker is installed, let's take a moment to make a few quality-of-life improvements. These will help make Docker a little easier to use on a day-to-day basis:

  • Enable Docker to start automatically after a reboot.
  • Allow the non-root user to manage Docker.
  • Install docker-compose.

Automatic start

In CentOS, Debian, and Ubuntu 16.04, systemd is responsible for managing which services start when the system boots up. That means you can enable this with a single command.

Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.