User:Sam/Quick Docker

From Gentoo Wiki
Jump to:navigation Jump to:search

Sometimes it's useful to be able to give a Dockerfile to e.g. upstreams to easily reproduce a bug.

Examples

Usage

Grab Docker itself:

root #emerge --ask app-containers/docker app-containers/docker-cli

Create the Dockerfile we're going to use (this example is for the libcap bug linked above):

FILE ~/docker/gentoo/Dockerfile
FROM gentoo/stage3

# Disable bits which don't work within Docker.
RUN echo 'FEATURES="-ipc-sandbox -pid-sandbox -network-sandbox -usersandbox -mount-sandbox -sandbox"' | cat >> /etc/portage/make.conf
# Speed things up a bit.
RUN echo 'FEATURES="${FEATURES} parallel-install parallel-fetch -merge-sync"' | cat >> /etc/portage/make.conf

RUN emerge-webrsync -q

# Do things you specifically want for your problem
RUN emerge --quiet --quiet-build=y dev-vcs/git
RUN git clone -q https://git.kernel.org/pub/scm/libs/libcap/libcap.git
CMD /bin/sh -c 'cd libcap && make clean COPTS="-m32 -O0 -g -ggdb3" -C libcap all test'

Run it:

user $mkdir -p ~/docker/gentoo && cd ~/docker
user $# Create the given Dockerfile
user $$EDITOR ~/docker/gentoo/Dockerfile
user $# Build the image
user $docker build -t gentoo gentoo/
user $# Run it (which builds & tries to run tests for libcap)
user $docker run -it gentoo

Tips

  • Use the desktop image if need e.g. Xorg for test suites (FROM gentoo/stage3:desktop)
  • Use the experimental binpkg host
# TODO: May be able to drop this once changed to desktop docker images?
# https://dilfridge.blogspot.com/2021/09/experimental-binary-gentoo-package.html
RUN echo -e "[binhost]\npriority = 9999\nsync-uri = https://gentoo.osuosl.org/experimental/amd64/binpkg/default/linux/17.1/x86-64/\n" | cat >> /etc/portage/binrepos.conf
RUN echo 'EMERGE_DEFAULT_OPTS="--binpkg-respect-use=n --getbinpkg=y --autounmask-write --autounmask-continue --autounmask-keep-keywords=y --autounmask-use=y"' | cat >> /etc/portage/make.conf