|
| 1 | +FROM ubuntu:jammy-20221130 as sysbox-builder |
| 2 | + |
| 3 | +ARG KERNEL_ARCH=amd64 |
| 4 | +ARG KERNEL_VERSION=5.15.0-58-generic |
| 5 | +ARG SYSBOX_COMMIT=v0.5.2 |
| 6 | + |
| 7 | +RUN apt-get update -y && apt-get upgrade -y && apt-get install --no-install-recommends -y \ |
| 8 | + linux-headers-$KERNEL_VERSION \ |
| 9 | + git \ |
| 10 | + make \ |
| 11 | + protobuf-compiler \ |
| 12 | + golang-goprotobuf-dev \ |
| 13 | + autoconf \ |
| 14 | + libtool \ |
| 15 | + golang-go \ |
| 16 | + ca-certificates \ |
| 17 | + automake \ |
| 18 | + kmod \ |
| 19 | + iproute2 \ |
| 20 | + lsb-release |
| 21 | + |
| 22 | +RUN git clone https://github.com/nestybox/sysbox && git -C /sysbox checkout $SYSBOX_COMMIT |
| 23 | + |
| 24 | +WORKDIR /sysbox |
| 25 | + |
| 26 | +# Taken from https://github.com/nestybox/sysbox/blob/master/.travis.yml |
| 27 | +RUN sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules && \ |
| 28 | + git submodule update --init && \ |
| 29 | + sed -i 's/[email protected]:/https:\/\/github.com\//' sysbox-fs/.gitmodules && \ |
| 30 | + sed -i 's/[email protected]:/https:\/\/github.com\//' sysbox-libs/.gitmodules && \ |
| 31 | + git -C sysbox-fs submodule update --init && \ |
| 32 | + git -C sysbox-libs submodule update --init |
| 33 | + |
| 34 | +RUN sed -i "s/\$(shell uname -r)/$KERNEL_VERSION/" Makefile |
| 35 | + |
| 36 | +RUN TARGET_ARCH=$KERNEL_ARCH make sysbox-local |
| 37 | +RUN make install |
| 38 | + |
| 39 | +# NOTE: This has been taken from https://github.com/nestybox/sysbox/blob/master/sysbox-in-docker/Dockerfile.ubuntu-focal with |
| 40 | +# focal being replaced with jammy |
| 41 | + |
| 42 | +# |
| 43 | +# Sysbox-In-Docker Container Dockerfile (Ubuntu-Focal image) |
| 44 | +# |
| 45 | +# This Dockerfile creates the sysbox-in-docker container image, which holds |
| 46 | +# all Sysbox binaries and its dependencies. The goal is to allow users to run |
| 47 | +# an entire Sysbox sandbox within a container. |
| 48 | +# |
| 49 | +# NOTE: Sysbox is a container runtime and thus needs host root privileges. As a |
| 50 | +# result, this image must be run as a privileged container, and a few resources |
| 51 | +# must be bind-mounted to meet Sysbox requirements as well as those of system-level |
| 52 | +# apps running in inner containers. Notice that within the privileged container, |
| 53 | +# inner containers launched with Docker + Sysbox will be strongly isolated from the |
| 54 | +# host by Sysbox (e.g., via the Linux user-namespace). |
| 55 | +# |
| 56 | +# Instructions: |
| 57 | +# |
| 58 | +# * Image creation: |
| 59 | +# |
| 60 | +# $ make sysbox-in-docker ubuntu-focal |
| 61 | +# |
| 62 | +# * Container creation: |
| 63 | +# |
| 64 | +# docker run -d --privileged --rm --hostname sysbox-in-docker --name sysbox-in-docker \ |
| 65 | +# -v /var/tmp/sysbox-var-lib-docker:/var/lib/docker \ |
| 66 | +# -v /var/tmp/sysbox-var-lib-sysbox:/var/lib/sysbox \ |
| 67 | +# -v /lib/modules/$(uname -r):/lib/modules/$(uname -r):ro \ |
| 68 | +# -v /usr/src/linux-headers-$(uname -r):/usr/src/linux-headers-$(uname -r):ro \ |
| 69 | +# -v /usr/src/linux-headers-$(uname -r | cut -d"-" -f 1,2):/usr/src/linux-headers-$(uname -r | cut -d"-" -f 1,2):ro \ |
| 70 | +# nestybox/sysbox-in-docker:ubuntu-focal |
| 71 | +# |
| 72 | + |
| 73 | +FROM ubuntu:jammy |
| 74 | + |
| 75 | +ENV DEBIAN_FRONTEND=noninteractive |
| 76 | + |
| 77 | +RUN apt-get update \ |
| 78 | + && apt-get install --no-install-recommends -y \ |
| 79 | + apt-utils \ |
| 80 | + ca-certificates \ |
| 81 | + wget \ |
| 82 | + curl \ |
| 83 | + iproute2 \ |
| 84 | + jq \ |
| 85 | + fuse \ |
| 86 | + rsync \ |
| 87 | + dialog \ |
| 88 | + kmod \ |
| 89 | + bash-completion \ |
| 90 | + && apt-get clean \ |
| 91 | + && rm -rf /var/lib/apt/lists/* \ |
| 92 | + && echo ". /etc/bash_completion" >> /etc/bash.bashrc |
| 93 | + |
| 94 | +# Install Docker. |
| 95 | +RUN curl -fsSL https://get.docker.com -o get-docker.sh |
| 96 | +RUN sh get-docker.sh |
| 97 | +ADD https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker /etc/bash_completion.d/docker.sh |
| 98 | + |
| 99 | +# S6 process-supervisor installation. |
| 100 | +ADD https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64-installer /tmp/ |
| 101 | +RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / |
| 102 | + |
| 103 | +ENV \ |
| 104 | + # Pass envvar variables to agents |
| 105 | + S6_KEEP_ENV=1 \ |
| 106 | + # Direct all agent logs to stdout. |
| 107 | + S6_LOGGING=0 \ |
| 108 | + # Exit container if entrypoint fails. |
| 109 | + S6_BEHAVIOUR_IF_STAGE2_FAILS=2 |
| 110 | + |
| 111 | +COPY s6-services /etc/services.d/ |
| 112 | +COPY sysbox.sh /etc/cont-init.d/ |
| 113 | + |
| 114 | +# Copy Sysbox artifacts. |
| 115 | +COPY --from=sysbox-builder /usr/bin/sysbox-mgr /usr/bin/sysbox-mgr |
| 116 | +COPY --from=sysbox-builder /usr/bin/sysbox-fs /usr/bin/sysbox-fs |
| 117 | +COPY --from=sysbox-builder /usr/bin/sysbox-runc /usr/bin/sysbox-runc |
| 118 | + |
| 119 | +ENTRYPOINT ["/init"] |
0 commit comments