Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Thursday, November 14, 2024

Update Home Assistant docker installation

In order to safely update your docker container in a Synology NAS. I assume you manage your docker containers via docker-compose

  1. List the running containers
    docker ps
  2. Go to the docker folder
    cd /volume1/docker
  3. Copy the configuration (if needed)
    cp -rp ha /volume2/backups/ha-bak.25.x
  4. Stop the container
    docker stop homeassistant
  5. Make a backup
    docker commit homeassistant homeassistant-backup:version-25.x
  6. Pull the latest image
    docker pull ghcr.io/home-assistant/home-assistant:stable

    or if you want a specific version
    docker pull ghcr.io/home-assistant/home-assistant:2024.11.3
  7. Remove the container
    docker rm homeassistant
  8. If you have a specific version to use, edit the version of the image in the docker-compose file to the downloaded one (2024.11.3, default is stable)
    vi docker-compose.yaml
  9. Start up the new container
    docker-compose --verbose up -d homeassistant

Checklist afterwards:

  • Check if configuration is loaded correctly:
    docker exec homeassistant python -m homeassistant --script check_config --config /config
  • Check for version: Settings > About
  • Check for logs: Settings > System > Logs
  • Update HACS plugins if needed
For a full recovery of a container:
  1. Stop and Remove the Current Container:
    docker stop homeassistant

    docker rm homeassistant
  2. Run a New Container from the Backup Image (or edit your docker-compose.yaml and start with docker-compose):
    docker run -d --name homeassistant \ --restart=unless-stopped \ -v /volume1/docker/ha:/config \ -e TZ=Europe/Paris \ --net=host \ homeassistant-backup:version-24.11


Thursday, September 21, 2023

Watchtower not working on Synology DSM 6.0.x as a Docker container

When installing the standard Watchtower container onto DSM 6.0 with Docker, I ran into 2 issues which caused the container not to run and constantly restart itself (see container logs for the error messages):

  1. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  2. Error response from daemon: client is newer than server (client API version: 1.24, server API version: 1.23

Both issues have a solution. First being that an older docker image has to be used, second being that DSM UI somewhere filters out a file mapping when creating the container.

Fix for issue 1: Create a symlink

sudo ln -s /var/run/docker.sock /volume1/docker/docker.sock

Fix for issue 2: Create a new docker container

sudo docker run -d --name watchtower-new -v /volume1/docker/docker.sock:/var/run/docker.sock centurylink/watchtower --interval 82800 --cleanup

Thanks to these links for finding a solution

Monday, August 2, 2021

Enter into the command prompt or shell of a running Docker container from the host command line

If you need to enter into the command prompt of a running Docker container:

sudo docker ps

And then enter the container by name or ID

sudo docker exec -i -t nginx-test /bin/bash

or

sudo docker exec -i -t e7a5s8dd2s3s4-test /bin/sh


Saturday, July 31, 2021

Separate Zwave gateway or hub with MQTT integration to Home Assistant

This post is based on the excellent tutorial found here.

I want to run my Zwave stick from another RPi than my HA installation and want all the data to become available within HA through MQTT.

In short, these are the major steps to take:

  1. Ensure you have a running HA & MQTT setup, mine are separate Docker images
  2. Check that your Zwave stick is being found on the RPi
  3. Install Docker on your RPi
  4. Install ZWavejs2MQTT
  5. Start your Docker image
  6. Configure Zwave
  7. Do a discovery and check whether your stick and potentially 1 or more Zwave sensors or actors are being found
  8. Configure MQTT (disable the Gateway functionality in this step)
  9. Configure the Gateway (enable the functionality again)
  10. Check within HA if a new entity for MQTT has been found, with your sensors or actors

Monday, March 18, 2019

Installing LibreNMS Docker image on Synology

At some point in time when you start having many devices in your home network, and you want to have some insight in things like bandwidth consumption, whether devices are alive, memory usage is ok... You have the need for a monitoring tool. I went for LibreNMS as it seemed user friendly with lots of features that are handy for a low-effort setup like auto-discovery. I went for the docker image from here. There are some excellent blogpost from other bloggers on how to setup this, but I ran into a few issues that I want to share with you. One issue that is still unresolved is running the web UI with https.


  1. Login to your NAS via SSH and make yourself root
  2. Follow the regular step by creating an APP_KEY in base64
  3. Create the MySQL user and database
  4. CREATE DATABASE librenms;
    CREATE USER 'librenms'@'%' IDENTIFIED BY 'yourpassword';
    CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'yourpassword';
    GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'%';
    FLUSH PRIVILEGES;
  5. I could only start the container with the following command which does not make use of the UID, GID and SSL config. I choose TCP port 30080 as my Synology is already serving other things over TCP port 80.
  6. docker run \
     -d \
     -h librenms \
     -p 30080:80 \
     -e APP_KEY="base64:your-app-key" \
     -e DB_HOST=192.168.0.Y \
     -e DB_NAME=librenms \
     -e DB_USER=librenms \
        -e TZ=Europe/Amsterdam \
     -e DB_PASS=yourpassword \
     -e BASE_URL=http://192.168.0.X:30080 \
        -e POLLERS=16 \
     -v /volume1/docker/librenms/logs:/opt/librenms/logs \
     -v /volume1/docker/librenms/rrd:/opt/librenms/rrd \
     -v /volume1/docker/librenms/ssl:/opt/librenms/ssl:ro \
     --name librenms \
     jarischaefer/docker-librenms
  7. When the container is started, from the command line you can monitor the logs from the container.
  8. Find the container ID
  9. docker ps
  10. Monitor the logs using the container ID
  11. docker logs container-id
  12. I did see these errors, which seems related to this Docker setup issue explained at Stackoverflow.. As the Docker setup on Synology is somewhat custom and probably prone to errors when you change something, I decided to ignore this.
  13. setfacl: /opt/librenms/bootstrap/cache: Operation not supported
    setfacl: /opt/librenms/logs: Operation not supported
    setfacl: /opt/librenms/rrd: Operation not supported
    ...
    
  14. I also had to remove the UID and GID from the Docker command as this was giving me the following error:
  15. failed to acquire lock schema
  16. So the posted command to launch the Docker container under step 4 is the one that worked for me.
  17. Next, setup the database, create an admin account for your user and login to the container to edit the configuration.
  18. docker exec librenms setup_database
    docker exec librenms create_admin
    docker exec librenms php /opt/librenms/adduser.php admin admin 10 you@here.com
    docker exec -it librenms bash
    Edit the LibreNMS config:
    vi /opt/librenms/conf.d/custom.php
    Set the SNMP community tag:
    $config['snmp']['community'][] = "public";
    $config['nets'][] = '192.168.0.0/24';
    $config['discovery_by_ip'] = true;
    Scan for SNMP devices:
    /opt/librenms/snmp-scan.py -r 192.168.0.0/24
  19. Normally, you should be able now to login into the web UI on http://192.168.0.X:30080. (note the default username/password for LibreNMS is admin:admin)
  20. The next thing I want to do is to figure out how Nginx can help serve LibreNMS over HTTPS with a reverse proxy. The current issue is the fact that base_url is being used as an environmental variable, which is causing all URLs to be always rewritten back to HTTP. No, this is not the expected behaviour. :-)

Sunday, February 10, 2019

Unifi Controller: setup a new instance and restore a backup

I tried to upgrade my Docker container with the Unifi Controller (UC) on my Synology. Unfortunately, upgrading from 5.6 to 5.10 is actually not supported and I ended up with a corrupted database. I therefore, created a new container from the latest stable image (5.10.12) and had a few hickups in between.

  1. I did not have a good backup of the MongoDB for version 5.6
  2. Always have good backups.
  3. I got I/O exception (java.net.ConnectException) caught when processing request...
  4. It turned out that I had already my SSL certificate placed inside the /unifi/cert folder, which caused this error. The /unifi data, logs and cert folder must thus be empty when you first start the container. Later on, you can update your certificates. Don't forget to restart the container when you do.
  5. The container (version 5.10) crashed when I restored a UC autobackup for version 5.6
  6. A restart and some patience for the system to come back on, helped this. A re-adoption of the devices was needed. I also upgraded the firmware of all my devices.

Saturday, February 9, 2019

Docker: update a container but take a backup first

You have ever downloaded a Docker image on your Synology and created a container out of it. Now like with the Unifi Controller, the software inside gets updated, so you also need to update the corresponding image. It's safe to take a backup of your container first before continuing.

Backup and restore of a container

  1. List the container you want to backup (the container must be running)
  2. docker ps
    Output:
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES 78727078a04b        debian:8            "/bin/bash"         13 seconds ago      Up 11 seconds                           unifi
  3. Take a snapshot of the running state
  4. docker commit -p  78727078a04b  unifi-20190209
    e09f9ac65c8b3095927c14ca0594868f73831bde0800ce66415afeb91aea93cf
  5. Verify that a snapshot has been stored with your images
  6. docker images
    REPOSITORY                      TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    unifi-20190209                  latest              e09f9ac65c8b        39 seconds ago      125.1 MB
  7. Save as a tar and archive, just in case
  8. docker save -o /volume1/docker/unifi/backups/unifi-20190209.tar unifi-20190209
    user:/volume1/docker/unifi/backups# ls -lh
    total 536M
    -rw------- 1 root root 536M Feb  9 08:59 unifi-20190209.tar
  9. If you want to restore, do a login first and then push the image
  10. docker login
    docker push unifi-20190209

Update a container on your Synology

  1. Login to your Synology DSM and go to the Docker app
  2. Go to the 'Image' repository. Check for the image that you started from and verify the tag you used (e.g. jacobalberty/unifi:stable)
  3. Go to the 'Container' part and stop the container that you want to update
  4. Go to the 'Registry' part and search for the image. When you found the corresponding image (e.g. jacobalberty/unifi), right click and choose 'Download this image'. You will start seeing the image being downloaded as the number 1 will appear next to 'Image'. Wait until the download is completed.
  5. Go back to the 'Container' part, select the container (it is still in stopped state). Click on 'Action' and click on 'Clear'. Do not click on Delete. The container will dissapear and reappear.
  6. Once it reappears, you can start it again.
More screenshots here.

Sunday, February 11, 2018

Pihole docker change or remove password

Below the steps to change or remove your Pihole admin password.

Login to your Docker host, next get a Docker shell:
docker exec -it pihole /bin/bash
Set a password for your pihole web interface
pihole -a -p somepasswordhere
You could also remove the password by not passing an argument
pihole -a -p

Tuesday, February 6, 2018

Installing (and updating) Unifi Controller as a docker image on your Synology NAS

Prerequisites


  • Make sure you log in to DSM on your NAS as an admin user.
  • Docker must be installed on your NAS. If It isn’t, go to "Package Center", select "Utilities" and look for "Docker" under the "Third-party" heading and add the package to your NAS (if Docker is not available for your NAS, this HOWTO is not for you).

Installation

  1. In the (DSM) Main menu, choose "Docker".
  2. Click on "Registry" and search for "unifi". Select the "jacobalberty/unifi" entry and click "Download". Select the "stable" branch.
  3. When the image is downloaded, it’ll show up under "Image", on this page select it and click "Launch". Note that it can take a while to finish the download, DSM will show a "system event" notification when download is completed.
  4. Give the controller a container name you like (or accept the default) and click on "Advanced Settings".
  5. In the first tab "General settings", check "Enable auto-restart"
  6. In the tab "Volume", click "Add Folder"
  7. Select "docker", click on "Create folder", name it "unifi" and click OK. Select it and click "Select"
  8. Under "mount path", enter "/unifi". Later on, you will see that subfolders data and log will be created. A subfolder folder cert can be manually created to host your SSL certificate.

  9. In the tab "Network", check "Use the same network as Docker Host". Click "Apply" and click on "Next" and after that on "Apply".
  10. Start your container and check the settings by selecting the running container and clicking on "Details".

Updating

  1. In the DSM Main menu, choose "Docker".
  2. Click on "Registry" and search for "unifi". Select the "jacobalberty/unifi" image and click "Download". Select the branch you installed before ("stable" is the branch you should choose). Wait until the download completes (DSM will show a "system event" notification when download has completed)
  3. Click on "Container", select the UniFi Controller container and subsequently:
    1. Stop the container (flip the on-off switch you see) and wait till the status of the container changes to "Stopped".
    2. Click the "Action" button and select "Clear".
    3. Start the container (flip the on-off switch you see) and wait till the status of the container changes to "Running".
That’s it! The new version of Unifi Controller should be running now.

Unifi controller docker image not working on Synology until...

I wanted to install a docker image into a running container using the fine work done by Jacob Alberty. And follow these steps. Unfortunately, I could not access the website on https://yournasip:8443. I was pulling my hairs out as I could see that the container was running, TCP IP4/6 ports were open, yet I could not access any website. I double checked that my firewall on the NAS was not blocking traffic, but that was not the case. I therefore reverted to starting the container from the command line. (Please note that I ommited the --init flag, as this flag (from 1.13 onwards) is not yet supported on the Docker version on my Synology (1.11.2).)

docker run --rm -p 3478:3478/udp -p 6789:6789/udp -p 8080:8080 \
-p 8443:8443 -p 8843:8843 -p 8880:8880 -p 10001:10001/udp -e TZ='Europe/Paris' \
-v /volume1/docker/unifi:/unifi --name unifi jacobalberty/unifi:stable

And tadaaa! Suddenly, I was able to access the Unifi Controller again. But when I stopped the command on the command line, the container would stop. So I needed a little trick.

  1. Start the docker container from the command line through an SSH session in the terminal.
  2. Verify that you can access the Unifi Controller
  3. Go to DSM and login, start the Docker app
  4. Click on 'Container' and identify the unifi container. Right-click it, go to Settings and then Duplicate Settings. A copy container will be made, named unifi-copy.
  5. Kill the docker command from the terminal. But now you have a second copy.
  6. Tweak and configure the copy container as you like and start it from the DSM.

Alternatively, you could also use the -d option as per documentation.
--detach , -dRun container in background and print container ID

Tuesday, February 28, 2017

Installing Unifi Controller as a Docker container on Synology


Having Ubiquiti UniFi access points in your house is a great way to serve a meshed Wifi network. With a Synology NAS and DSM6, it's very easy now to run the UniFi Controller in a Docker container. Link to the docker image: https://hub.docker.com/r/jacobalberty/unifi/
These tutorials will greatly help you with that: miketabor.com and kapsi.fi. There's a few tweaks I had to make:
Change the container config and add UDP port 10001:10001
Make sure your firewall rules on your NAS are properly adapted (take the 10001/udp into account as well)

If you have deployed a UniFi Controller on a different system/instance before, make sure that you adopt the device on your new Controller by doing the following steps:
SSH login to your access point (access_point_ip:22) with credentials of the previous controller (e.g. administrator:yoursecretpass)
Now execute the following commands:
#mca-cli
#set-inform synology_nas_ip:8080/inform

Now you should see your device into your new Controller instance and you're good to go!

Tuesday, February 14, 2017

Installing Crashplan docker image to Xpenology or Synology

Following the excellent tutorial by Mike Tabor, the only difference to my setup, was the need to change my local config for this location: C:\Users\username\AppData\Local\CrashPlan\.ui_info instead of the mentioned one.