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

first attempt to build an official Docker image #1896 #3381

Closed
wants to merge 3 commits into from

Conversation

splitbrain
Copy link
Collaborator

@splitbrain splitbrain commented Jan 14, 2021

Details can be found in docker/README.md

Please pay special attention to the todos listed in the readme. I need some help with this. Pull requests against this branch welcome.

Details can be found in docker/README.md
@fschrempf
Copy link

Trying to run this with the proposed command from the docs causes the following error for me:

$ docker run --name dokuwiki -it -v /tmp/volume/:/overlay/storage --cap-add=SYS_ADMIN -p 8090:80 splitbrain/dokuwiki
mount: /var/www/html: cannot mount overlay read-only.

Only when I add --privileged it actually works. Does this mean --cap-add=SYS_ADMIN doesn't provide enough permissions to create the overlayfs?

@splitbrain
Copy link
Collaborator Author

Hmm good question. SYS_ADMIN is enough on my system. Might be a question of docker and kernel version?

$ docker --version
Docker version 20.10.1, build 831ebeae96
$ uname -a
Linux rumpel 5.9.14-arch1-1 #1 SMP PREEMPT Sat, 12 Dec 2020 14:37:12 +0000 x86_64 GNU/Linux

@fschrempf
Copy link

Hmm good question. SYS_ADMIN is enough on my system. Might be a question of docker and kernel version?

Possible. I'm not really a docker expert, unfortunately. I'm running the 5.10 kernel. Not sure if that's enough to explain the different results.

$ docker --version
Docker version 20.10.1, build 831ebeae96
$ uname -a
Linux tp-fs 5.10.2-2-MANJARO #1 SMP PREEMPT Tue Dec 22 08:14:42 UTC 2020 x86_64 GNU/Linux

docker/entrypoint.sh Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
As suggested by @glensc
@splitbrain splitbrain force-pushed the docker branch 13 times, most recently from 8ec88a5 to 12c524a Compare January 18, 2021 18:19
@crazy-max
Copy link

@splitbrain If you're interested you can take some inspiration with my image: https://github.com/crazy-max/docker-dokuwiki

@terribleplan
Copy link

terribleplan commented Feb 3, 2021

This is an interesting approach for sure, but I fear that the need for the container to have CAP_SYS_ADMIN may be a non-starter for some, it's a very broad privilege (even referred to as "overloaded" and "the new root" in man capabilities). I wonder if there is some better way to accomplish the same goal.

I'm glad to see thought and effort being put toward this regardless.

@michitux
Copy link
Collaborator

michitux commented Feb 3, 2021

What about just dropping that capability after mounting? Then the security impact should be minimal.

@splitbrain
Copy link
Collaborator Author

I guess the same could be achieved using a FUSE based overlay FS like https://github.com/containers/fuse-overlayfs When I have time I'll do some tests.

@splitbrain
Copy link
Collaborator Author

Hmm seems like fuse needs a privileged container as well. I didn't expect that, what a bummer. @michitux how would I drop the privileges after mounting?

@glensc
Copy link
Contributor

glensc commented Feb 4, 2021

Hmm seems like fuse needs a privileged container as well. I didn't expect that, what a bummer. @michitux how would I drop the privileges after mounting?

A quick search gave me this page:

so, in entrypoing script, instead of invoking bash or httpd (whatever) you execute via capsh:

exec capsh --drop=cap_net_raw --print -- -c "/bin/ping -c 1 localhost"


ARG BRANCH=stable

COPY --chmod=755 ./entrypoint.sh /usr/local/sbin/entrypoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to rename not to be so generic name, so in case you want/need to wrap and execute another one, like you do with the php entrypoint:

exec docker-php-entrypoint apache2-foreground

if the parent image also had it named as entrypoint you would need to make workarounds.

Hence, I propose to use a file named dokuwiki-entrypoint when installing (doesn't matter how you name it in your git repository).

VOLUME /overlay/storage

# setup DokuWiki
RUN mkdir -p /overlay/original && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN mkdir -p /overlay/original && \
RUN set -x && \
mkdir -p /overlay/original && \

I like the shell to show what commands are executed, eases debug and has no downside for the final image.

@thomaskchan
Copy link

Trying to run this with the proposed command from the docs causes the following error for me:

$ docker run --name dokuwiki -it -v /tmp/volume/:/overlay/storage --cap-add=SYS_ADMIN -p 8090:80 splitbrain/dokuwiki
mount: /var/www/html: cannot mount overlay read-only.

Only when I add --privileged it actually works. Does this mean --cap-add=SYS_ADMIN doesn't provide enough permissions to create the overlayfs?

I have the same issue running docker 20.10.3 on Debian Buster. Adding privileged works for docker run, but privileged can't be used in swarm mode.

@splitbrain
Copy link
Collaborator Author

I am closing this PR. I agree that the requirement of elevated privileges makes this approach impractical for real life use.

@splitbrain splitbrain closed this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants