Setup and Install Portainer on Synology NAS

Currently reading
Setup and Install Portainer on Synology NAS

The Synology Docker UI is nice but lacks some functionality such as Stacks, Templates and other useful things that can make managing your containers a lot easier. Portainer will run seamlessly along side the Synology Docker UI.

First make a folder on your Synology to hold the portainer data and
make sure you change the path /volume1/docker/portainer in the example to match yours.

Continue reading...
 
Another image update and this happened again. Checked my IP and it was fine. The only way I saw to overcome this was to delete the container and recreate it from scratch.

FWIW, I imported a settings backup and it also failed to connect.

Am I the only one seeing this when updating Portainer? I use the download image/stop container/clear container/restart container method FWIW.
You cant update via ui. docker.sock and all that. The container that you recreate has no connection that’s why you get an error.

Download the image, delete the container and recreate it via docker run/compose with all the parameters needed.
 
What I did last time the Portainer image was updated:

Within Portainer, download the latest image. Then, via SSH, ran these commands (replace /volume1/docker/portainer, in the third command, with whatever you use)...

Bash:
sudo docker container stop $(sudo docker container ls -a | grep portainer/portainer | awk '{print $1}')

sudo docker container rm $(sudo docker container ls -a | grep portainer/portainer | awk '{print $1}')

sudo 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

All we're doing is being lazy and using docker container and striping out the Portainer container's ID, then stopping this ID and removing it. Next re-making the container with the new image.
 
All we're doing is being lazy and using docker container and striping out the Portainer container's ID, then stopping this ID and removing it. Next re-making the container with the new image.

If you create your container with docker-compose it is even lazier than that. If use the latest tag for your image, it boils down to docker-compose pull && docker-compose up -d. If you work with exact version tags, you simply edit the tag in your docker-compose.yml and just to the docker-compose up -d part, as it will pull the new exact version tag and re-create the container using it.

While docker-compose is a first class citizen for QNAP Docker UI users, it is no citizen for Synology Docker UI users at all. If Syno's custom docker engine would work with Portainer Stacks, we would have at least a way to manage docker-compose without entering the shell.. It is a shame that it doesn't work (due to Synologies customizations on the docker engine!).
 
Syno's custom docker engine would work with Portainer Stacks, we would have at least a way to manage docker-compose without entering the shell.. It is a shame that it doesn't work (due to Synologies customizations on the docker engine!).
You said it!
 
Last edited:
I could swear I wrote that the binding needs to be made specificaly.... ;)

Edit your daemon.json / dockerd.json (see the exact path above) as root and add following content:


If your daemon.json already includes lines, just add the "hosts" line.
You may need to add a "," (without double quotes) to the previous line's end - or to the "hosts" line if a line follows it.

Make sure to restart the docker service after the modifcation:
- on Syno: restart the docker package
- On any other Linux os: execute the command sudo service docker restart


Then use "host-ip:2375" as the endpoint. Make sure the port is NOT accessible from the internet, as basicly everyone could remote control your docker engine!

I've managed to get the Portainer agents working. I find that a little more secure as the agent and portal needs to be configured with a 'secret' before this works. So I want to reverse what I did above so I no longer need to have port 2375 exposed with the docker engine. Ofcourse I didn't make it accessible from the internet, but never take security lightly.. :)

So I'll be removing this line:
1604230137499.png



Then restart the docker package on this NAS, and hopefully it will still work... :)

EDIT: successfull
 
So has anyone already got Portainer running with two endpoints?

That said, I've successfully set up Portainer running on my 918+ and would like to manage docker on my DS916+, too.

Guess, it's not an easy task, according to Add Docker Endpoint - Documentation and Portainer: Managing Docker Engines remotely over TCP socket (TLS)
Simpley start a portainer agent on the “client” nas and add it to your mail portainer host

Code:
docker run -d --name portainer_agent  -p 9001:9001 -v /var/run/docker.sock:/var/run/docker.sock --pid=host portainer/agent

More info here:
 
Never mind, got it running by editing dockerd.json on the second NAS, adding the appropriate line as mentioned somewhere here in this thread, restarted the docker service and all is up now!

For the records: runnign the container using the shell command for the first time, worked like a charm, however each subsequent start of the Portainer container failed, I forgot to map the previously created symlink to docker.sock in Portainer.
Code:
ln -s /var/run/docker.sock /volume1/docker/docker.sock

Thanks!
 
Simpley start a portainer agent on the “client” nas and add it to your mail portainer host

Code:
docker run -d --name portainer_agent  -p 9001:9001 -v /var/run/docker.sock:/var/run/docker.sock --pid=host portainer/agent

More info here:

You do not use an agent secret to add security?
 
What am I doing wrong...yml...

Code:
version: "3"
    container_name: portainer
    image: portainer/portainer-ce:latest
    ports:
      - 8000:8000/tcp
      - 9000:9000/tcp
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /volume1/docker/portainer/data:/data

Leaves me with this error (running as sudo -i)

docker-compose pull
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 2, column 5
 
You missed to declare the high-level "services:" element, and an element for the service itself, which I called "portainer:". All elements you had are child nodes of the "portainer" service element.
Code:
version: "3"
services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:latest
    ports:
      - 8000:8000/tcp
      - 9000:9000/tcp
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /volume1/docker/portainer/data:/data

Note: version: "3" is NOT the latest 3.x, it equals to 3.0. Are you sure you want to use "3"?
 
You missed to declare the high-level "services:" element, and an element for the service itself, which I called "portainer:
Originally I had this which was autogenerated (using the Dutch script from another thread here)... (which failed with row/column errors) and I believe those elements are present

Code:
version: "3"
services:
  portainer:
    container_name: portainer
    entrypoint:
      - /portainer
    environment:
      - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    hostname: b5a02cc0f67c
    image: portainer/portainer-ce
    ipc: shareable
    logging:
      driver: db
      options: {}
    mac_address: 02:42:ac:11:00:0b
    networks:
      - bridge
    ports:
      - 8000:8000/tcp
      - 9000:9000/tcp
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    working_dir: /
networks:
  bridge:
    external: true

I started chopping out pieces and retrying without success.

I'll try again with another container. I'm trying to move to the command line for docker execution. I ended up removing the portainer container and using docker run.
 
Last edited:
Try this, it's been working extremely well for me:

Code:
version: "2"
services:
  portainer-ce:
    image: portainer/portainer-ce:latest
    container_name: portainer

    ports:
      - 8000:8000
      - 9000:9000

    volumes:
      - ./data:/data
      - /var/run/docker.sock:/var/run/docker.sock


    restart: always
 
Your compose file should smth like this after removing the unnecessary elements:
Code:
version: "3"
services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce
    networks:
      - bridge
    ports:
      - 8000:8000/tcp
      - 9000:9000/tcp
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
networks:
  bridge:
    external: true

This pretty much is like the previous configuration, except this time it has a declaration to use the existing bridge network. If you remove that part, then a (stack private!) default network will be created (though isn't it created anyways?) and you container will be joined the default network.

Though: it is impossible this compose.yml can be deployed successfully... In the service's volumes section, the volume "portainer_data" is used, but it's not declared in the high level configuration item volumes.... Either you removed to much, or the export generated a broken compose.yml. You might want to replace the volume portainer_data with a host-path to convert it to a bind-mount.
 
Last edited:
Though: it is impossible this compose.yml can be deployed successfully... In the service's volumes section, the volume "portainer_data" is used, but it's not declared in the high level configuration item volumes.... Either you removed to much, or the export generated a broken compose.yml. You might want to replace the volume portainer_data with a host-path to convert it to a bind-mount.
Thank you.

When I use "docker run". .. "portainer_data" seems equally declared, and it runs fine.

Code:
`docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce`

What is the difference... When I look it up under "volumes" in Portainer, after using the docker run command... I see this:
VAO41pZ.png
 
Docker compose files require an item level declaration of used networks and volumes - regardless whether they prexist or not. Your compose file had it for networks, but lacked the volumes part.

Docker run and Portainer's container create handle this differently: they expect the volumes and networks to exist. I'd be suprised if Portainer would accept the incomplete compose.yml for stack creation - it shouldn't as it's invalid according the docker compose file schema of the version (actualy of any version).
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

  • Article
Today I will show you how to setup your Synology to be used as storage on Proxmox. You can use it to store...
Replies
0
Views
3,904
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below...
Replies
0
Views
2,805
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below. - - - Check out FREE NAS...
Replies
0
Views
1,354
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below. - - - Check out FREE NAS...
Replies
0
Views
1,240
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below. - - - Check out FREE NAS...
Replies
0
Views
2,077
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below. - - - Check out FREE NAS...
Replies
0
Views
1,390
  • Article
Welcome to NASCompares YouTube channel! Check out our next video below. - - - Check out FREE NAS...
Replies
0
Views
1,529

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Back
Top