Docker

The discussion lounge for third-party packages.
Forum rules
Please note the Disclaimer before modifying your Synology Product.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Docker

Postby Fizzyade » Sat Feb 18, 2017 3:14 pm

The official docker is crippled by the method in which containers are started by the synology API, I have used the latest docker binaries and using the official synology docker package as a template created a docker replacement.

THIS IS ONLY FOR INTEL X64 AND I HAVE ONLY TESTED IT ON A DS916+

Here's a link to the SPK, it installs the latest version of docker as a package called Docker Unofficial.

Notes:

DON'T INSTALL UNLESS YOU KNOW WHAT YOU ARE DOING!!!

It uses the latest docker binaries grabbed from the docker site.

It uses a binary named "auplink" which I grabbed from the official Synology Docker image.

The startup script is basically cobbled together from the official Docker image (loads the modules, set's up links etc)

If you start the script via the command line, you will see some errors, these are caused by mod probe being broken on synology (they don't have a /lib/modules/{version}) so the daemon makes a couple of mod probe calls at the start, but fortunately doesn't bomb out. The modules it complains about are actually installed.

It also moans about /etc/os-release, again this file is missing on the synology, no biggie.

Both the Official Docker and this Version store their docker files inside their own respective packages, so you won't be able to use existing containers - again, not a biggie as normally the container doesn't store the data and you store that elsewhere (the beauty of docker!).

Don't blame me if it all goes wrong.

There is no interface inside DSM for this, you will need to manage your containers either from the command line or a web interface. You can install portainer buy running:

docker run --name portainer -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /volume1/docker/portainer:/data --restart always portainer/portainer

You'll need to set the data volume to something sensible for your machine. It starts portainer with --restart always, when the daemon shuts down it remembers that the container was running and will restart it the next time the daemon is started, so at boot or by starting and stopping the package from the package manager.

If you install portainer you can access the portainer gui on: http://<ip>:9000/ (IP is the IP of your nas), select local docker when it asks you, the demon is started with a socket .file so portainer can access it.

If you're paranoid, probably not best to use this. If you are paranoid and want to use it, then you could rebuild the SPK file with downloaded files from the docker site and also extract the auplink file from the official docker package.

Feel free to modify and make this better!

https://drive.google.com/file/d/0B8Mm6F ... sp=sharing
Last edited by Fizzyade on Thu Feb 23, 2017 1:27 pm, edited 1 time in total.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 21, 2017 9:11 am

Just replaced the package with a new version (same link as above) - installs 1.13.1-009 (009 is my versioning of the package):

* Now will only install on x86_64 (figured out arch from Synology Docker)
* Fixes loss of containers & images after update of package (was storing root inside the container/
* Added Symlinks for a couple more docker binaries
* Now uses the /<volume>/@docker and /<volume>/docker locations which means it shares its containers & images with the synology docker, I haven't actually tested this but I assume it works (can't think of a reason it wouldn't). You can only have one running at once.
* Works fine under ext4, no idea about btrfs, I couldn't get that to work but have since reformatted the disk as ext4, so it happily uses aufs.
* I had to add iptables -P FORWARD ACCEPT as a rule in the docker start script so that containers using bridges can access the network

I'm using this without any issues whatsoever on my DS916+, I have now completely removed the official synology docker package.

Notes:

Portainer cannot list the tasks in this version, this is because the "ps" command on the synology requires an extra switch "-D" to list the docker tasks, it is quite easy to modify portainer to support this (I've done it) but it requires a fairly long winded method to generate and then import the image.

you can use docker top <container> -efD to show the running tasks in a container though.

Also note you'll need to stop the official Synology Docker package to run this one.

Obviously you'll need to allow unsigned packages to install.
usrKalman
Trainee
Trainee
Posts: 12
Joined: Tue Mar 29, 2016 11:29 am

Re: Docker

Postby usrKalman » Mon Feb 27, 2017 5:19 pm

Hi,

I am using a container app in docker. The app is licensed based on the physical (MAC) address of the container. So far it runs OK, When I Stop then Start the container the MAC address changes (increments by 1) so the licensing fails. I know how to use "docker run -d --mac-address=xx:xx:xx:xx:xx:xx:xx CONTAINER" to create a new instance. However that requires the full restart of the app. What I would need is to be able to set the MAC address of an existing container not to change with restarting (or be able to set when restarting it). I use DS1815+ DSM version: DSM 5.2-5644 Update 5
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Mon Feb 27, 2017 11:44 pm

usrKalman wrote:Hi,

I am using a container app in docker. The app is licensed based on the physical (MAC) address of the container. So far it runs OK, When I Stop then Start the container the MAC address changes (increments by 1) so the licensing fails. I know how to use "docker run -d --mac-address=xx:xx:xx:xx:xx:xx:xx CONTAINER" to create a new instance. However that requires the full restart of the app. What I would need is to be able to set the MAC address of an existing container not to change with restarting (or be able to set when restarting it). I use DS1815+ DSM version: DSM 5.2-5644 Update 5


You can't, you cannot change the parameters that the container was started with without recreating it. (O.k there are a couple of minor exceptions).

The synology docker allows you to change stuff (mounts, environment variables) but I assume it does this with a re-image and delete and then new creation of the container. I suspect the increasing MAC address is a direct effect of this.

For the most part, a delete and rebuild of the container should not cause an issue - containers should store their data outside the container so that you can update the underlying image without loss of data, however, whether all images do this is another matter.
EvilFP
I'm New!
I'm New!
Posts: 6
Joined: Mon May 23, 2016 1:02 am

Re: Docker

Postby EvilFP » Tue Feb 28, 2017 3:11 am

Thanks for making this Fizzyade. Much cleaner than my approach to running docker binaries.
usrKalman
Trainee
Trainee
Posts: 12
Joined: Tue Mar 29, 2016 11:29 am

Re: Docker

Postby usrKalman » Tue Feb 28, 2017 8:01 am

Thank you for your reply. The strange is, that the Restart (alternatively Stop then Start) made from the Synology Docker app GUI forces the MAC address to change without recreation of the container (docker run .....). The MAC change may be a result of a function taking the IP address as a parameter and indeed the IP address is changed at Restart. I can observe the increment on both of them.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 28, 2017 10:55 am

usrKalman wrote:Thank you for your reply. The strange is, that the Restart (alternatively Stop then Start) made from the Synology Docker app GUI forces the MAC address to change without recreation of the container (docker run .....). The MAC change may be a result of a function taking the IP address as a parameter and indeed the IP address is changed at Restart. I can observe the increment on both of them.


The Synology docker is very weird, I believe it is doing a recreation of the image but possibly by creating a new image from the container and then restarting that, it's all hidden away so it's not possible to really tell (and to be honest, I haven't investigated it much) - after all, it does allow you to modify parameters in the synology GUI, but all other docker UI systems I've come across that allow you to do this have to re-create the container, when you do a docker start you cannot change any parameters. When you hit start in the docker gui it is not issuing a "docker start" command, it is doing something else.

If you create a container in the official synology docker and then use only docker commands (docker start and docker stop) to start and stop the container you will see that no changes occur to the container, so if you've for example added a device mapping then that will remain. The moment that you hit start on a container in the docker GUI these are lost, I assume at this point it creates a new container (most likely from an image of the current container state) and starts that with the current set of parameters that you have selected.

The whole reason I went down this whole other route of creating an alternative docker application is because of this, the fact that the synology GUI breaks containers with the mechanism it uses to start them, that and the fact that you cannot do anything advanced to start a container.

Basically, the synology docker GUI is a PITA. While it appears nice in that you can start containers easily and set parameters and change them, it does this in a manner which makes it impossible to keep more advanced containers running properly.
Last edited by Fizzyade on Tue Feb 28, 2017 10:58 am, edited 1 time in total.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 28, 2017 10:57 am

EvilFP wrote:Thanks for making this Fizzyade. Much cleaner than my approach to running docker binaries.


No worries, it was born out of frustration for the official synology docker!

This might not be perfect (you may have to fiddle with the start-stop-script), but it works 100% for me and means that I can run stuff properly which I cannot do in the synology docker application.
usrKalman
Trainee
Trainee
Posts: 12
Joined: Tue Mar 29, 2016 11:29 am

Re: Docker

Postby usrKalman » Tue Feb 28, 2017 2:31 pm

Fizzyade wrote:
usrKalman wrote:Thank you for your reply. The strange is, that the Restart (alternatively Stop then Start) made from the Synology Docker app GUI forces the MAC address to change without recreation of the container (docker run .....). The MAC change may be a result of a function taking the IP address as a parameter and indeed the IP address is changed at Restart. I can observe the increment on both of them.


The Synology docker is very weird, I believe it is doing a recreation of the image but possibly by creating a new image from the container and then restarting that, it's all hidden away so it's not possible to really tell (and to be honest, I haven't investigated it much) - after all, it does allow you to modify parameters in the synology GUI, but all other docker UI systems I've come across that allow you to do this have to re-create the container, when you do a docker start you cannot change any parameters. When you hit start in the docker gui it is not issuing a "docker start" command, it is doing something else.

If you create a container in the official synology docker and then use only docker commands (docker start and docker stop) to start and stop the container you will see that no changes occur to the container, so if you've for example added a device mapping then that will remain. The moment that you hit start on a container in the docker GUI these are lost, I assume at this point it creates a new container (most likely from an image of the current container state) and starts that with the current set of parameters that you have selected.

The whole reason I went down this whole other route of creating an alternative docker application is because of this, the fact that the synology GUI breaks containers with the mechanism it uses to start them, that and the fact that you cannot do anything advanced to start a container.

Basically, the synology docker GUI is a PITA. While it appears nice in that you can start containers easily and set parameters and change them, it does this in a manner which makes it impossible to keep more advanced containers running properly.


Fizzyade, your detailed description how it works is perfect. I have tested docker stop and docker start issued from SSH terminal. It works as you wrote without loosing and/or re-creating the configuration, so I can preserve the license once I have it. What is sad about it that even experienced users have no option left how to make use of the Syno docker app. Thank you again.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 28, 2017 3:06 pm

usrKalman wrote:
Fizzyade wrote:
usrKalman wrote:Thank you for your reply. The strange is, that the Restart (alternatively Stop then Start) made from the Synology Docker app GUI forces the MAC address to change without recreation of the container (docker run .....). The MAC change may be a result of a function taking the IP address as a parameter and indeed the IP address is changed at Restart. I can observe the increment on both of them.


The Synology docker is very weird, I believe it is doing a recreation of the image but possibly by creating a new image from the container and then restarting that, it's all hidden away so it's not possible to really tell (and to be honest, I haven't investigated it much) - after all, it does allow you to modify parameters in the synology GUI, but all other docker UI systems I've come across that allow you to do this have to re-create the container, when you do a docker start you cannot change any parameters. When you hit start in the docker gui it is not issuing a "docker start" command, it is doing something else.

If you create a container in the official synology docker and then use only docker commands (docker start and docker stop) to start and stop the container you will see that no changes occur to the container, so if you've for example added a device mapping then that will remain. The moment that you hit start on a container in the docker GUI these are lost, I assume at this point it creates a new container (most likely from an image of the current container state) and starts that with the current set of parameters that you have selected.

The whole reason I went down this whole other route of creating an alternative docker application is because of this, the fact that the synology GUI breaks containers with the mechanism it uses to start them, that and the fact that you cannot do anything advanced to start a container.

Basically, the synology docker GUI is a PITA. While it appears nice in that you can start containers easily and set parameters and change them, it does this in a manner which makes it impossible to keep more advanced containers running properly.


Fizzyade, your detailed description how it works is perfect. I have tested docker stop and docker start issued from SSH terminal. It works as you wrote without loosing and/or re-creating the configuration, so I can preserve the license once I have it. What is sad about it that even experienced users have no option left how to make use of the Syno docker app. Thank you again.


You'll still have an issue at reboot though because unfortunately the synology docker manually starts the containers just as if you had pressed "start" in their GUI, so on reboot the container will start up in the same manner. :(.

This is the very reason that I created my unofficial docker package so that you can create a container with "--restart always" as the switch (this is one of the ones you can add to an already existing container) and when the docker daemon starts up, it automatically restores the running containers (in the right order if they have links).

It's quite infuriating that synology have decided that being able to "change parameters and mounts" is more important than preserving the container, almost as infuriating as not documenting that this is the behaviour.

As an aside you might be able to sort the Mac address inside your container by changing it with a startup script to your fixed Mac, this will obviously override the behaviour that is occurring because of the synology container "management".
sincarne
Navigator
Navigator
Posts: 971
Joined: Wed Feb 15, 2017 9:57 pm

Re: Docker

Postby sincarne » Tue Feb 28, 2017 7:31 pm

I am confuse. In Docker Synology there is option 4 auto-restart. Are you talking something different?
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 28, 2017 7:42 pm

sincarne wrote:I am confuse. In Docker Synology there is option 4 auto-restart. Are you talking something different?


Yes. The restart option in the synology docker package is broken in anything that requires a more advanced configuration because the docker daemon is not in charge of restarting the containers, DSM is.

Once you run containers with more advanced options (like device mappings or various other things) the synology docker package does not know about these and looks like it snapshots the container as an image and then starts the snapshot (so you can change environment variables and folder mappings) in its own manner but while doing this it loses any options that you used to start the container in the first place.

Basically, if you start a container with any extra switches then hitting start in the synology docker gui or restarting the diskstation will lose these.
Fizzyade
Novice
Novice
Posts: 52
Joined: Mon Jan 02, 2017 1:06 pm

Re: Docker

Postby Fizzyade » Tue Feb 28, 2017 10:12 pm

EvilFP wrote:Thanks for making this Fizzyade. Much cleaner than my approach to running docker binaries.


Just to let you know, I updated the SPK again. Noticed today that I'd left in no-iptables switch when starting the daemon which causes problems with bridge mode. I don't think you were using bridge mode so you wouldn't have seen the problem.
Vidadoora
Rookie
Rookie
Posts: 33
Joined: Sun Aug 30, 2015 1:33 am

Re: Docker

Postby Vidadoora » Fri Mar 17, 2017 6:10 am

This looks interesting I didn't know this kind of modification was possible - does this mean that Synology models which currently don't support Docker (e.g. DS415play, Intel Evansport processor) could get Docker if someone released an unofficial mod like this ? Thanks, M.
dipole
Rookie
Rookie
Posts: 31
Joined: Mon May 23, 2016 12:37 am

Re: Docker

Postby dipole » Fri Mar 17, 2017 12:45 pm

I'm thinking of playing around with this, but before i do, how would I go about uninstalling this spk if I wanted to go back to DSM Docker?

Return to “Third-party Packages”

Who is online

Users browsing this forum: No registered users and 7 guests