Duplicati docker installation - Docker in Docker support

Hello everyone,

I’m using the following Docker image for my Duplicati installation: linuxserver/duplicati.

I want to execute scripts before and after my backups. Specifically, I need to stop other Docker containers before starting the backup to avoid issues when backup their files. While I successfully managed to run a script before my backup, I encountered a problem:

The script generates warnings indicating that there is no Docker installation inside the Duplicati container. To resolve this, I attempted to create a custom Docker image based on the linuxserver/duplicati image. However, this image is built on Debian Jammy, and I ran into compatibility issues when trying to follow the Docker installation tutorial for Debian: Install Docker Engine on Debian.

Does anyone have any advice or suggestions for solving this issue? Any help would be greatly appreciated!

Thanks in advance,
T

Welcome to the forum @TiTan

has discussion, and then notes:

You can do this with the Linuxserver.io version of the docker. Just pass in DOCKER_MODS=linuxserver/mods:code-server-docker and it will install the binaries. Also, like you already said, don’t forget to mount the docker socket.

I went to track this down, starting at their web site:

https://github.com/linuxserver/docker-mods

https://mods.linuxserver.io/

click CODE-SERVER then DOCKER

https://github.com/linuxserver/docker-mods/tree/universal-docker

which surprised me until I located this:

https://github.com/linuxserver/docker-mods/tree/code-server-docker

saying it’s deprecated so use linuxserver/mods:universal-docker

I don’t use Docker, but this seems like a facility to get what you want.

1 Like

Thank you that worked properly.
I have a further question.
I configured my script as “run-script-before-required”.
But if I hit the “backup now” button, the progress bar in the top suggest, that duplicati starts to build the backup artifact, before it runs the script.
But in that case the pre script did not stop the database docker container which should prevent some inconsistent database states in the backup files.
Is it just a UI bug or does it really start the backup process before it run the scripts?:

How did you determine when the script actually ran?

“pre” scripts should run before screenshot you show.

Can you make the script do something you’d notice?

Adding in a “sleep 10” has mine delay before backup.

or

You can test the exit code. See run-script-example.sh

etc.

Is this a theoretical result or did you see this happen?
If container didn’t stop, script or setup could be faulty.

From Duplicati or some other way?

Apologies for the confusion earlier. It turns out the pre-script, which stops my container and performs a software update, was running so quickly (likely because no update was necessary) that it immediately started the backup process. After some trial and error, everything now appears to be working perfectly as expected.

To improve stability, I added set -eo pipefail at the top of my scripts. This ensures that any errors in the script cause it to exit immediately and avoids unintended behavior.

For anyone encountering a similar issue in the future, here’s an important note about Docker setups, especially when dealing with Docker-in-Docker configurations:

Key Issue:

You cannot mount relative paths inside a Docker-in-Docker setup. For example, if you mount a directory like this:
"./data:/data/"

It will work fine on your host system—for instance, it will resolve to something like:
/home/user/your_server/data:/data/.

However, if you then mount /home/user/your_server/ to /source/ in your Duplicati container, and later attempt to restart the container using docker-compose, your host system will interpret this mount as:
/source/data:/data/.

This will break the expected behavior because the relative paths within the Duplicati container won’t resolve correctly to the host system’s absolute paths. But your docker is executed on your host system.

Solution:

To fix this issue, always mount your server directories to the same absolute path in the Duplicati container. For example:

/home/user/my_server:/home/user/my_server

By doing this, any relative paths inside the Duplicati container will correctly map to the corresponding absolute paths on your host system. This ensures consistency and prevents path resolution issues.


I hope this explanation helps anyone facing a similar problem! Let me know if you have further questions or need clarification.

2 Likes

Do you mind sharing your full compose file for Duplicati. I am also trying to use docker commands in pre and post backup script. But running into some issues. Also refer my post to see if you can help me out. Appreciate in advance.

Of course:

services:
    duplicati:
        image: linuxserver/duplicati:latest
        restart: unless-stopped
        environment:
            - PUID=0
            - PGID=0
            - TZ=Europe/Berlin
            - DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:universal-git
        volumes:
            - ./config:/config
            - ./scripts:/scripts
            - /home/titan/servers/:/home/titan/servers/ # here you see I mounted the original path to the exact same position in the docker container to prevent the above mentioned issue
            - /mnt/:/mnt/ # you don't need this line. I included it because I mounted there my external hdd
            - /var/run/docker.sock:/var/run/docker.sock
        ports:
            - 8200:8200
1 Like