Portainer - Docker Container Manager For Your NAS
Tags: synology, docker, nas
Published: 2021-01-25 15:48:00

---
title: Portainer - Docker Container Manager For Your NAS
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/3epsn6anxvsrqb6s60tp.jpg
date: 2021-01-25 00:00:00 UTC
tags: Synology,Docker,NAS
canonical_url: https://chrisotto.dev/portainer-docker-nas/
series: Synology NAS Setup
---

Image courteous of [Pixabay](https://pixabay.com/).

Portainer is an application that makes it easy for you to manage docker containers that you have running on your system. It is a great tool to add to any NAS running containers or homeserver doing the same. It can also be used for Kubernetes management if that is something you have running or are interested in. Some of the features I like:

- SSH into the container right from the UI
- View logs
- See resources consumed by each container

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#prerequisites-)Prerequisites 📃

- Download Docker from Package Center
  - In DSM head over to Package Center
  - Search for Docker
  - Install
- Enable SSH for your NAS
  - If you don’t have SSH enabled follow this [guide](https://dev.to/chrisotto/synology-nas-ssh-to-find-user-info-396a).

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#create-folder-structure-)Create Folder Structure 📂

In DSM, open up the File Station:

- Installing docker creates a `docker` folder at the root of your volume
- Create a new folder in the `docker` folder for Portainer
  - I always create the folder based on the name of the image/container I’m setting up, in this case, `portainer`

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#ssh-into-your-nas-and-run-the-image-)SSH Into Your NAS And Run the Image 📦

Using your preferred terminal SSH into your NAS, once logged in run the following:

```bash
%USERNAME%@%NAS_NAME%:~$sudo su -
```

You may be prompted to re-enter your password and you should do so. This command puts us in the root environment with the root user. Your terminal windows should now look like this:

```bash
root@%NAS_NAME%:~#
```

Copy and paste the following snippet in your terminal

```bash
root@%NAS_NAME%:~# docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /volume1/docker/portainer:/data portainer/portainer-ce@latest
```

If you have any other containers already setup that may be using ports `8000` or `9000` make sure to change that before executing the Docker run command. Now we just have to set up the portainer instance in the web interface and we’ll be all set!

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#setup-portainer-)Setup Portainer 🛳

In your browser navigate to `http://%SYNOLOGY_IP_ADDRESS%:9000`. Here we will be prompted to create a new user for Portainer.

- Create your username
- Create a new password
- Confirm your password
- Uncheck `Allow collection...`
- Click `Create User`

Once your user is created you will be brought to a screen to choose which container environment we want to manage with Portainer.

- Select Docker (or if you are using this to manage Kubernetes then choose that one)
- Click `Connect`

Now you should be looking at the Portainer dashboard, congratulations you have successfully set up Portainer in your NAS/homeserver through Docker! Feel free to get out their [image](https://hub.docker.com/r/portainer/portainer-ce) in Docker Hub or the Community Edition [documentation](https://www.portainer.io/products/community-edition) for more information! Cheers! 🍻