From 7289315837cf611e30c1c89f7f2d511ff468cf55 Mon Sep 17 00:00:00 2001 From: Brett Bertocci Date: Fri, 13 Jul 2018 15:54:18 -0700 Subject: [PATCH] Ensure the /lib/modules symlink to /host/lib/modules is set correctly If /lib/modules exists in the base image, the symlink will get created at /lib/modules/modules. This removes any existing empty directory but will fail if we try to remove a non-empty /lib/modules. (Punting on how to handle non-empty base image dirs for now) --- docker/dev/Dockerfile | 6 +++++- docker/local/Dockerfile | 6 +++++- docker/stable/Dockerfile | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 81f1a801..622e8431 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -48,7 +48,11 @@ RUN curl -s https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public | && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules +# Some base images have an empty /lib/modules by default +# If it's not empty, docker build will fail instead of +# silently overwriting the existing directory +RUN rm -df /lib/modules \ + && ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules COPY ./docker-entrypoint.sh / diff --git a/docker/local/Dockerfile b/docker/local/Dockerfile index 574786b2..1e86d2bc 100644 --- a/docker/local/Dockerfile +++ b/docker/local/Dockerfile @@ -41,7 +41,11 @@ RUN rm -rf /usr/bin/clang \ && ln -s /usr/bin/clang-7 /usr/bin/clang \ && ln -s /usr/bin/llc-7 /usr/bin/llc -RUN ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules +# Some base images have an empty /lib/modules by default +# If it's not empty, docker build will fail instead of +# silently overwriting the existing directory +RUN rm -df /lib/modules \ + && ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules ADD falco-${FALCO_VERSION}-x86_64.deb / RUN dpkg -i /falco-${FALCO_VERSION}-x86_64.deb diff --git a/docker/stable/Dockerfile b/docker/stable/Dockerfile index f52f4c56..4a2a968b 100644 --- a/docker/stable/Dockerfile +++ b/docker/stable/Dockerfile @@ -47,7 +47,11 @@ RUN curl -s https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public | && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules +# Some base images have an empty /lib/modules by default +# If it's not empty, docker build will fail instead of +# silently overwriting the existing directory +RUN rm -df /lib/modules \ + && ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules COPY ./docker-entrypoint.sh /