FROM gentoo/portage:latest as portage
FROM gentoo/stage3-amd64:latest

COPY --from=portage /usr/portage /usr/portage

        EMERGE_DEFAULT_OPTS="--jobs=9 --load-average=8 --with-bdeps=y" \
        MAKEOPTS="-j9 -l8" \
        USE="cairo introspection jpeg tiff"

RUN emerge app-text/poppler \
        dev-python/pycairo \
        dev-python/pygobject \
        dev-util/ccache \
        media-libs/exiftool \
        media-libs/mutagen \
        sys-apps/bubblewrap \
        virtual/ffmpeg \

Building the image

From inside the my_build directory, we’ll use the docker build command, passing the -t flag to “tag” the new image with a name, which in this case will be my_image. The . indicates that the Dockerfile is in the current directory, along with so-called “context” — that is, the rest of the files that may be in that location:

cd ~/my_build
docker build -t my_image .
docker image ls

Start an interactive bash session

docker run -it --entrypoint /bin/bash my_image

if you add --rm the container gets deleted if you exit it --privileged to give extended privileges to this container

enable user_namespaces in the kernel

For unprivileged 'unshare'

sysctl -w kernel.unprivileged_userns_clone=1