Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to start the container as non-root user #47

Closed
ttionya opened this issue Mar 6, 2022 · 3 comments
Closed

Support to start the container as non-root user #47

ttionya opened this issue Mar 6, 2022 · 3 comments
Labels
enhancement New feature or request type: backup

Comments

@ttionya
Copy link
Owner

ttionya commented Mar 6, 2022

Now the container cannot be started as a non-root user, because crond can only be started as root user.

Find ways to start crond as a non-root user, or find alternatives to crond, such as aptible/supercronic or gjcarneiro/yacron. Not limited to the above two.

In Development.

@ttionya ttionya added enhancement New feature or request type: backup labels Mar 6, 2022
@kevdogg
Copy link

kevdogg commented Mar 8, 2022

So I don't know a lot about Dockerfiles, however within the dockerfile, cant you initially install the required packages and start the required daemons and then create a user/group and then switch to that user?

@ttionya
Copy link
Owner Author

ttionya commented Mar 10, 2022

So I don't know a lot about Dockerfiles, however within the dockerfile, cant you initially install the required packages and start the required daemons and then create a user/group and then switch to that user?

The container is still started as root by default. But you can set - user: user:group in docker-compose.yml to specify the user and group to start the container.

@ttionya
Copy link
Owner Author

ttionya commented Jun 29, 2022

I've tried a lot to support start container as a non-root user. Next I explain the problems encountered.

The first problem is timezone. The backup tool symlinks the files in /usr/share/zoneinfo/ to the /etc/localtime based on the environment variable TIMEZONE when the container is started. It makes date and cron use the correct timezone. But the /etc directory is owned by the root user, so only the root user can write any files to it.

Of course there are other ways to solve this problem, a chain of symlinks, /etc/localtime -> /tmp/localtime -> /usr/share/zoneinfo/UTC, but the creation of the symlinks happens during the docker build phase, and the created /tmp/localtime is owned by root user, the non-root user at the time of starting the container cannot re-establish a symlink to /tmp/localtime. I haven't tried to establish the effect of invalid symlinks on date and cron.

The second is that BusyBox cron does not support non-root user to start, even with setcap. I found out that dcron can be started as a non-root user, but it hasn't been maintained for a long time, I prefer to use cronie if it supports non-root user start.

It was fatal that the output of the script could not be redirected to the stdout when using dcron, but the good news is that this problem has been solved, see dubiousjim/dcron#33.

The third issue, is directory permissions. We recommend mounting vaultwarden data volumes to /bitwarden/data/, but the owner of the /bitwarden directory is root, so non-root users cannot create other directories in /bitwarden, which is the working directory of the backup tool, and the wrong permissions will cause backup errors.

Since this is only a backup tool and will not be accessed externally, it was not considered to support non-root user to start the container, so the design of the directory did not consider the permission issue at all. But if we modify the directory now, it will cause break change.

I will look for other better solutions to support non-root users to start containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request type: backup
Projects
None yet
Development

No branches or pull requests

2 participants