Blog

Docker management with Portainer on DigitalOcean

By:
on:

Until some time ago we used Docker Cloud to manage our web applications.
But with Docker Cloud shutting down these services, we had to find a new way to setup and manage our applications.
So we set out to look at and try out some of the available solutions.
Among these were Docker swarm mode, Kubernetes, Portainer and other platforms that provide Docker services.

Choosing Portainer

After messing around a bit we've found Portainer to be a good match for us, combined with DigitalOcean's Droplets.
Portainer is a manager ui for Docker environments, it simply connects to a system that's got Docker running and lets you manage images, containers, services, etc.
It's open source, you can check it out on github.
Without having to connect to your server yourself with ssh and inputting loads of commands, this makes managing a collection of Docker services much easier.
Additionally, using Portainer gives us a lot of control over how and where we deploy our applications, and we're running both Portainer and our apps on DigitalOcean.

Most importantly for us it gives us:

  • easy access to our application stacks and their compose files
  • easy management of images, containers, secrets, volumes, as well as many other docker features
  • quick access to all of our running applications from the same location

How does this work on DigitalOcean?

On DigitalOcean we have one Droplet on which we run Portainer.
Then for each project we have another Droplet on which we're putting our application's Docker containers, this is simply a server on which we install Docker and set it up to be remotely managed.
Portainer then connects to each individual Droplet and manages Docker, and through Docker, our application and its containers.
Then when an application is running, we can still tweak the settings, manage secrets, scale services and more without taking the entire application down.
And since behind the scenes it's still Docker doing all the work, you can expect everything to work just the same as it does on your own system.

Adding a new application

To create a new application we create a new Droplet running Ubuntu with Docker installed.
Now we'll need to enable the tcp socket in Docker to make it available from the outside.
We do this by creating the file `/etc/systemd/system/docker.service.d/override.conf`

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375

and then restarting Docker.

$ systemctl daemon-reload
$ systemctl restart docker.service

New we need to add a new endpoint to Portainer, endpoints you've added tell Portainer which Docker environments to manage.
Adding a portainer endpoint
We need to provide a name and URL, the rest is optional. The endpoint URL is the ip address of the Droplet on port 2375.
After clicking 'Add endpoint' our new application is available for management.

Here's some information on the Docker daemon and setting up tcp with systemd:

One more thing

I'd also like to mention Swarmpit, another management ui for Docker.
It works very much the same, letting you manage every aspect of a Docker environment.
A big difference however is that with Swarmpit you can only manage one endpoint.
You can't add multiple endpoints, on the contrary you need to run Swarmpit from the same system that the Docker you want to manage is running on.
If you've only got one Docker environment you need to manage, Swarmpit is a very good choice. Otherwise I'd recommend Portainer.

KOEN IS HAPPY TO INTRODUCE APPSALOON
APPSALOON BV
Bampslaan 21 box 3.01
3500 Hasselt
Belgium
VAT: BE08 4029 5063
2021 © AppSaloon All Rights Reserved
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram