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

COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo

    EMERGE_DEFAULT_OPTS="--jobs=4 --quiet" \
    FEATURES="-sandbox -usersandbox -ipc-sandbox -network-sandbox -mount-sandbox -pid-sandbox" \
    MAKEOPTS="-j4" \

RUN emerge dev-vcs/git app-portage/repoman dev-util/pkgcheck \
 && rm -rf /var/cache/distfiles/*

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

Gitlab Container Registry

docker login -u <username> -p <token>
docker build -t .
docker push