Skip to content

Instantly share code, notes, and snippets.

@DaveMDS
Forked from ta264/get-docker.sh
Last active November 14, 2024 07:37
Show Gist options
  • Save DaveMDS/c35d77e51e0186a4fe2e577f51a5b09a to your computer and use it in GitHub Desktop.
Save DaveMDS/c35d77e51e0186a4fe2e577f51a5b09a to your computer and use it in GitHub Desktop.
Install docker on arm64 synology
#!/bin/bash
set -e
ARCH=aarch64
DOCKER_VERSION=20.10.9
COMPOSE_VERSION=2.5.1
DOCKER_DIR=/volume1/@docker
echo "Downloading docker $DOCKER_VERSION-$ARCH"
curl "https://download.docker.com/linux/static/stable/$ARCH/docker-$DOCKER_VERSION.tgz" | tar -xz -C /usr/local/bin --strip-components=1
echo "Creating docker working directory $DOCKER_DIR"
mkdir -p "$DOCKER_DIR"
echo "Creating docker.json config file"
mkdir -p /usr/local/etc/docker
cat <<EOT > /usr/local/etc/docker/docker.json
{
"storage-driver": "vfs",
"iptables": false,
"bridge": "none",
"data-root": "$DOCKER_DIR"
}
EOT
echo "Creating docker startup script"
cat <<'EOT' > /usr/local/etc/rc.d/docker.sh
#!/bin/sh
# Start docker daemon
NAME=dockerd
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="--config-file=/usr/local/etc/docker/docker.json --pidfile=$PIDFILE"
case "$1" in
start)
echo "Starting docker daemon"
# ulimit -n 4096 # needed for influxdb (uncomment if your limit is lower)
/usr/local/bin/dockerd $DAEMON_ARGS &
;;
stop)
echo "Stopping docker daemon"
kill $(cat $PIDFILE)
;;
*)
echo "Usage: "$1" {start|stop}"
exit 1
esac
exit 0
EOT
chmod 755 /usr/local/etc/rc.d/docker.sh
echo "Creating docker group"
egrep -q docker /etc/group || synogroup --add docker root
echo "Installing docker compose $COMPOSE_VERSION"
curl -SL "https://github.com/docker/compose/releases/download/v$COMPOSE_VERSION/docker-compose-linux-$ARCH" \
--create-dirs -o /usr/local/lib/docker/cli-plugins/docker-compose
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
chgrp -R docker /usr/local/lib/docker
echo "Starting docker"
/usr/local/etc/rc.d/docker.sh start
echo "Done. Please add your user to the docker group in the Synology GUI and reboot your NAS."
@FlaTEriC1983
Copy link

Hi, unfortunately it doesn't seem to have worked for me... I used you're "installer", I can see the group, I added my user to it, but even after reboot, I can't find anything related to docker (package, icons or settings). The process dockerd is "sleeping". Any advice? I'm on DS120j.

@DaveMDS
Copy link
Author

DaveMDS commented Nov 22, 2022

Hi, this is not supposed to installing any docker GUI in your NAS.
after installing you should be able to use docker from the command line

@khalo-sa
Copy link

On my DS216j I am getting this after install, once the startup script is run:

/usr/local/etc/rc.d/docker.sh: line 10: /usr/local/bin/dockerd: cannot execute binary file: Exec format error

It seems like /usr/local/bin/dockerd is not suitable for my target platform. uname -m on my machine yields "armv7l". Is it the same for you @DaveMDS ?

@DaveMDS
Copy link
Author

DaveMDS commented Nov 28, 2022

No, my synology is aarch64.
you must change the first line of the script to match your arch (ARCH=xxx)

available docker build are available at:
https://download.docker.com/linux/static/stable/

I'm not sure if this will work, but you should try armel or armhf

@khalo-sa
Copy link

No, my synology is aarch64. you must change the first line of the script to match your arch (ARCH=xxx)

available docker build are available at: https://download.docker.com/linux/static/stable/

I'm not sure if this will work, but you should try armel or armhf

tried both, armel and armhf. both lead to the mentioned error not showing up, however the docker daemon still didn't start, so I gave up :/

@killkrt
Copy link

killkrt commented Dec 23, 2022

Same as @khalo-sa here, I've downloaded the armhf version on a DS218J (armv7), but I get a segmentation fault when I try to start the service.

@DaveMDS
Copy link
Author

DaveMDS commented Dec 25, 2022

This is why my script is called: "Install docker on arm64 synology" :D

@killkrt
Copy link

killkrt commented Dec 27, 2022

Yeah, I know, I was referring to:

I'm not sure if this will work, but you should try armel or armhf

Just as your information it seems that it is not working just downloading the armhf version, it seems that an extra patch it is needed.

@thunermay
Copy link

@killkrt Did this resolve? I have an DS214+ and thus an armv7l processor. How did you get it to work with armv7l or where did you find help. Thanks in advance!

@killkrt
Copy link

killkrt commented Mar 9, 2023

@thunermay sorry I cannot recall it, actually I was supporting a friend, so it was not for my NAS. BTW it was quite tricky and it was not fully working, some features were missing (if I am not wrong macvlan and others).

@cmbuckley
Copy link

My DS418's umask seems to default to 0077, so I needed to make the following change to use docker compose:

@@ -57,7 +57,7 @@
 echo "Installing docker compose $COMPOSE_VERSION"
 curl -SL "https://github.com/docker/compose/releases/download/v$COMPOSE_VERSION/docker-compose-linux-$ARCH" \
      --create-dirs -o /usr/local/lib/docker/cli-plugins/docker-compose
-chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
+chmod -R ug+rx /usr/local/lib/docker
 chgrp -R docker /usr/local/lib/docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment