Table of Contents
What is Docker?
Docker is a lightweight virtualization application that gives you the ability to run thousands of containers created by developers from all over the world on your Synology NAS. The hugely popular built-in image repository, Docker Hub, allows you to find shared applications from other talented developers.
Docker is available as an add-on package for the Synology NAS. Before you start, check if Docker is supported on your Synology NAS model. You can find this information in the Applied Models section by following the link below. As a rule of thumb, you can say that all models with an Intel or AMD processor can also run Docker.
Two important Docker terms that we will discuss are images and containers.. Images can exist without containers, whereas a container needs to run an image to exist. Therefore, containers are dependent on images and use them to construct a run-time environment and run an application.
For more information on Docker, you can also refer to Docker official documents, including Docker Swarm, Docker Compose, and Docker CLI.
Why use Docker?
On a Synology NAS you can use so-called Synology add-on packages to run applications. Just like the Docker add-on package itself. So why should you use Docker?
- One reason would be the huge ecosystem of available Docker images that you can find on Docker Hub.
- Synology announced the end-of-life for a lot of Synology packages. That could also be a reason to take a look at Docker.
- Third-party packages need updating when a new Synology DSM version is released. Docker images do not have this limitation and will work without change.
- Another reason may be that you want to keep Synology DSM and the applications better separated. Docker is well suited for this.
Having said this, there are a range of Synology packages that are specially developed for use with a Synology NAS. These packages are often more tightly integrated into the Synology ecosystem. While there are sometimes good Docker alternatives out there, there is also something to be said to keep using these native packages. Choosing a Synology package or a Docker alternative is something you can best decide for yourself.
Despite the fact that a Synology NAS can be less powerful compared to certain server hardware, in practice it appears that you can run quite a few Docker containers on it. It must be said that a memory upgrade is recommended if you are going to use Docker structurally.
Install Docker on Synology NAS
First of all we have to install Docker. Simply open the Synology Package Center, search for Docker and install the package. Once you installed it, the Docker package should have a status of Running.
You can then open the Docker package. The overview page should appear and show some information about CPU and RAM usage as well as the running Docker containers.
Let’s have a closer look at the different pages.
Overview
On the overview page, you can view the total amount of the available CPU and RAM that is being used by the containers you have created on Docker. Additionally, you can easily monitor the profiles of all your enabled containers.
Container
On the Container page, you can view the statuses of your containers, including their CPU and RAM usage. You can also manage and configure other additional settings or view the details for each container. You can also export container settings to easily transfer the data to another Synology NAS which also supports Docker.
Registry
The Registry page allows you to download image files from the storage server. You can easily use the vast image resources on Docker Hub, or your own resources on privately configured repository servers.
Image
On the Image page, you can manage all the images on your Synology NAS, and select images to create containers. Additionally, you can also easily add images from files or URL’s.
Network
This page will guide you through setting up and managing the Docker network.
Log
On the Log page, you can track the actions of users within a set period of time. You can view the log in its entirety, or use the filter to only view certain events.
For more detailed information about the available pages, you can have a look at the following Synology Help article.
Where to store your data?
Installing Docker was of course the most important step. As additional preparation I recommend to spend some thoughts on where to store persistent data of the Docker containers. Since the installation has already created a shared folder called docker, it is a good idea to use it.
Using a dedicated shared folder for persistent volumes will also simplify backups, which we should consider later.
Creating container from image
If you want to deploy a container, I suggest you to read the guide for each Docker image provided on Docker Hub first. It’s always recommended to read the information pages of the images before creating containers, as some information may be crucial regarding creating containers.
As an example let’s have a look at one of the images that is shown in the Registry page. In this example we will pick nginx (pronounced “engine-x”) and use it as a web server.
To create a Docker container, open the Docker package, go to the Registry page and select the nginx image. Then double-click on the entry in the list and select the desired version of the image. We will pick the latest version.
Then go to the Image page where you will see that the image is being downloaded. Once it is fully available, select the image from the list and click on launch. Enter the name you want to use for the new container.
For further configuration like port mappings, volumes, networks etc. there is a separate dialog available. Switch to it by clicking on the button for Advanced Settings.
From the nginx page on Docker Hub we see that we can share some static content by adding a volume to the configuration. The mount path of the static content is expected in /usr/share/nginx/html
. Because we are going to maintain the content on the Synology NAS we can mark it as read-only.
In the shared folder docker that was created by the Docker installation, we create a subfolder mynginx/html
where we will store the static content in index.html
.
<html>
<head>
</head>
<body>
<h1>Hello World!<h1>
</body>
</html>
Code language: HTML, XML (xml)
The subfolders can be created using File Station. You can create the index.html
file on your computer and upload it using File Station as well.
In this example, we will also adjust the local port. This is the port on the Synology NAS where the nginx web server is listening.
After completing the container creation, we can test the nginx web server by opening http://DiskStation:8080 in the browser. If everything is set up correctly, you will see the message Hello World!.
Managing containers
A nice thing is that there is an Overview page available in the Synology user interface. It shows all containers and some details together with information about the current resource utilization in total and per container.
Besides this overview there is the container section which can be used to start, stop and manage containers. It shows all containers in a list and offers several actions if you select one of the containers.
Backup considerations
If you store all volumes in the shared folder docker that was created by the Docker installation, it is quite easy to create a backup of that shared folder with for example the Synology Hyper Backup package.
The container configuration itself can be exported from the Container page, by selecting one of the containers and start the export from the Settings menu. If you store the export in the same shared folder where the volumes are stored, then the export file is also backed up. As a result you have the volumes as well as the container configuration in one place.
Because the configuration only changes if you modify the container configuration, something that doesn’t happen very often, a manual backup will be sufficient.