This Python script automates the process of upgrading the Docker version in an ASUSTOR NAS .apk package. It downloads the latest Docker binaries, replaces the binaries and version in the original .apk, preserves helper files, and notifies you via a Discord webhook when a new .apk is created.
It does not automate the installation of the APK on your NAS. That part still needs to be done manually. For obvious reasons, I don't want that aspect automated right now.
- Fetches Latest Docker Version: Scrapes Docker’s download page to find the latest stable release (e.g.,
docker-28.0.4.tgz). - Version Check: Compares the current
.apkversion with the latest Docker version to avoid redundant processing. - Updates APK:
- Updates the
general.versioninconfig.json(insidecontrol.tar.gz). - Replaces Docker binaries in
data.tar.gz’sbindirectory while preserving other helper files. - Creates a new
.apknameddocker_$VERSION.apk(e.g.,docker_28.0.4.apk).
- Updates the
- Discord Notification: Sends a message to a Discord webhook when a new
.apkis generated, including version and file details.
- Python 3.6+ - I think? Probably works on older versions since it is fairly basic. The version of Python3 that ADM has in the store is 3.10.11 and there is no issues running this script directly from there.
- Python Library:
requests(install viapip install requests). - Original APK: An ASUSTOR Docker
.apkfile. You can download this directly from Asustor's site (https://appdownload.asustor.com/0010_999_1732245556_docker-ce_25.0.5.r1_x86-64.apk) then name itoriginal_docker.apkand keep it in the scripts root folder. - Discord Webhook (optional): For notifications when a new
.apkis created.
-
Save the Script:
- Place
upgrade_docker_asustor.pyin a directory (e.g.,/path/to/asustor_docker_creator/).
- Place
-
Place Original APK:
- Copy your ASUSTOR Docker
.apkto the script’s directory and name itoriginal_docker.apk. - Alternatively, edit
ORIGINAL_APKin the script to point to your.apkpath:ORIGINAL_APK = Path("/path/to/asustor_docker_creator/original_docker.apk")
- Copy your ASUSTOR Docker
-
Install Dependencies:
- Install the
requestslibrary:pip install requests
- Install the
-
Set Discord Webhook (Optional):
- Create a webhook in your Discord server (Channel → Edit → Integrations → Create Webhook).
- Copy the webhook URL and update
DISCORD_WEBHOOK_URLin the script:DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks/your-webhook-id/your-webhook-token"
- If unset, notifications are skipped.
-
Make Executable (Linux):
- On Linux, make the script executable:
chmod +x main.py
- On Linux, make the script executable:
-
Schedule with Cron:
- Add the script to cron for periodic checks. If your running directly on the NAS you need to call
python3directly like in the example below.crontab -e 0 4 */5 * * /usr/local/bin/python3 /volume1/path/to/scripts/asustor_docker_creator/main.py
- The above cron is to run at 0400 every 5 days. I try to be a good internet citizen and not hammer their servers constantly for something that doesn't have a frequent release.
- Add the script to cron for periodic checks. If your running directly on the NAS you need to call
-
Monitor Notifications:
- When a new
.apkis created, you’ll receive a Discord message with the version, filename, and path. - Manually grab the
.apk(e.g.,docker_28.0.4.apk) and install it on your ASUSTOR NAS via ADM (App Central → Manual Install).
- When a new
- Architecture: Assumes
x86_64for Docker binaries. For ARM-based NAS, updateDOCKER_BASE_URL:DOCKER_BASE_URL = "https://download.docker.com/linux/static/stable/aarch64/"
- Helper Files: Non-Docker files in
data/binare preserved, assuming they have unique names. - Webhook Security: Keep your Discord webhook URL private.
- Testing: Test manually before automating to ensure the output
.apkworks on your NAS. - Version Check: Skips processing if
original_docker.apk’s version matches the latest Docker release.