ttionya / vaultwarden-backup

Backup vaultwarden (formerly known as bitwarden_rs) SQLite3/PostgreSQL/MySQL/MariaDB database by rclone. (Docker)
MIT License
1.07k stars 122 forks source link

Difficulty running this container as non-root user -- Suggestions? #45

Closed kevdogg closed 2 years ago

kevdogg commented 2 years ago

I took your image and rebuilt is using a Dockerfile:

FROM ttionya/vaultwarden-backup:latest

# Referenced image uses busybox

ENV BITWARDEN_GID=8081
ENV BITWARDEN_UID=8081
ENV BITWARDEN_USER=bitwarden
ENV BITWARDEN_GROUP=bitwarden

RUN addgroup -g $BITWARDEN_GID bitwarden
RUN adduser -u $BITWARDEN_UID -G $BITWARDEN_GROUP -D -H -g '' $BITWARDEN_USER

USER $BITWARDEN_USER

I then started the container to create the config like this:

sudo docker run --rm -it --mount type=bind,source=/home/bitwarden/.config/vaultwarden_backup,target=/config --user 8081:8081 bitwardenrs-rclone:latest rclone config

The container started, however the directory that was created --> /home/bitwarden/.config/vaultwarden_backup/rclone --> was owned by the root user. The container however tried to write rclone.conf within this directory as the non-root user, however it could create this file due to permissions.

In summary -- the rclone subdirectory was created as the root user, but the rclone.conf file was created as the non-root user.

ttionya commented 2 years ago

Hey @kevdogg ,

I tried to run the container with a non-root user (with --user 8081:8081) and generate a new configuration file, but the owner of the /home/bitwarden/.config/vaultwarden_backup/rclone directory is 8081.

Make sure you use user 8081 every time you run the container? Try deleting the /rclone directory and retry.

ttionya commented 2 years ago

See #47