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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

@splitbrain
Copy link
Owner

@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

@fschrempf fschrempf commented Jan 14, 2021

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
Owner Author

@splitbrain splitbrain commented Jan 14, 2021

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

@fschrempf fschrempf commented Jan 14, 2021

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 Jan 18, 2021
@splitbrain splitbrain force-pushed the docker branch from 12c524a to 4690037 Jan 18, 2021
@crazy-max
Copy link

@crazy-max crazy-max commented Jan 18, 2021

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

@terribleplan
Copy link

@terribleplan 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 michitux commented Feb 3, 2021

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

@splitbrain
Copy link
Owner Author

@splitbrain splitbrain commented Feb 3, 2021

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
Owner Author

@splitbrain splitbrain commented Feb 3, 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?

@glensc
Copy link
Contributor

@glensc 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

This comment has been minimized.

@glensc

glensc Feb 4, 2021
Contributor

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 && \

This comment has been minimized.

@glensc

glensc Feb 4, 2021
Contributor

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

@thomaskchan thomaskchan commented Feb 16, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants