Hello all,
For last few months I been using Tailscale as a docker image on my:
Raspberry pi 4 - 2gig memory - LibreELEC (official): 12.0.1 (RPi4.aarch64)
So I have written a bash script to install the Tailscale docker image and update the Tailscale image when needed with Watchtower.
Regards: peter
Remember to backup first before setting up Tailscale docker image !!
Install LibreELEC Docker app before you run the tailscale.sh bash script to install Tailscale docker image.
Add-ons / Install from repository / LibreELEC Add-ons / Services / Docker
## Below are the commands to set up the files that are needed.
touch /storage/.config/tailscale.sh
chmod +x /storage/.config/tailscale.sh
## Copy & Paste the lines below to: tailscale.sh
#!/bin/sh
# Script to check if Tailscale Docker image is installed
# and update it if needed using Watchtower.
# Temporary files for storing results
TAILSCALE_IMAGE_RESULT="/var/tmp/tailscale_image_result"
TAILSCALE_UPDATE_RESULT="/var/tmp/tailscale_update_result"
# Docker command for running Tailscale container
TAILSCALE_DOCKER_IMAGE="docker run -d \
--name=docker-tailscaled \
-v /storage/.config/dockers/tailscale/var/lib:/var/lib \
-v /dev/net/tun:/dev/net/tun \
--network=host \
--privileged \
--restart unless-stopped \
tailscale/tailscale tailscaled"
# Docker command for using Watchtower to update the Tailscale container
WATCHTOWER_DOCKER_IMAGE="docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower --run-once docker-tailscaled"
# 1. Clean up old Docker images (optional)
# Uncomment the line below to enable cleaning up old images
# docker system prune -f
# 2. Check if Tailscale container is already running
docker ps -a | grep -c "docker-tailscaled" > $TAILSCALE_IMAGE_RESULT
# 3. Read the result into a variable
IMAGE_RESULT=$(cat $TAILSCALE_IMAGE_RESULT)
# 4. If Tailscale is not installed (IMAGE_RESULT == 0), install it
if [ "$IMAGE_RESULT" -eq 0 ]; then
echo "Tailscale container not found, installing..."
eval $TAILSCALE_DOCKER_IMAGE
else
echo "Tailscale container is already installed."
fi
# 5. Check if an update is required for Tailscale
docker exec docker-tailscaled tailscale update | grep -c "no update needed" > $TAILSCALE_UPDATE_RESULT
# 6. Read the update result into a variable
UPDATE_RESULT=$(cat $TAILSCALE_UPDATE_RESULT)
# 7. If update is required, run Watchtower to update the container
if [ "$UPDATE_RESULT" -eq 0 ]; then
echo "Update required for Tailscale. Running Watchtower to update..."
eval $WATCHTOWER_DOCKER_IMAGE
else
echo "Tailscale is up to date."
fi
Display More
To install the Tailscale docker image run the command shown below from the directory .config
When Tailscale image is installed. You can check to see if it is up and running with the command shown below:
To setup Tailscale execute the command shown below to get the Tailscale login url
This will give you a url so you can log into your Tailscale account and connect your LibreELEC device to your tailnet.
#
Before you set a Tailscale exit node, use the command below:
The command above will allow you to have ssh access to your LibreELEC from your local network.
## To auto update the Tailscale image I use autostart.sh script to run the tailscale.sh script which will check if the Tailscale image needs updating. If so Watchtower will update the Tailscale image.
touch /storage/.config/autostart.sh
chmod +x /storage/.config/autostart.sh
## Copy & Paste the lines below to: autostart.sh
The file below tailscale.commands is just handy notes to help setup Tailscale.
touch /storage/.config/tailscale.commands
## Copy & Paste the lines below to: tailscale.commands
### Docker commands to manage tailscale setup.
docker exec docker-tailscaled tailscale
docker exec docker-tailscaled tailscale up
docker exec docker-tailscaled tailscale status
docker exec docker-tailscaled tailscale set --exit-node-allow-lan-access=true
docker exec docker-tailscaled tailscale exit-node list
docker exec docker-tailscaled tailscale exit-node suggest
docker exec docker-tailscaled tailscale update
### Docker commands to remove all images and volums.
# To delete all containers including its volumes use,
docker rm -vf $(docker ps -aq)
## To delete all the images,
docker rmi -f $(docker images -aq)
docker system prune
docker image ls
Display More