Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created August 19, 2016 19:26
Show Gist options
  • Save shoaibi/755f7d05570e54c266401a53917f658a to your computer and use it in GitHub Desktop.
Save shoaibi/755f7d05570e54c266401a53917f658a to your computer and use it in GitHub Desktop.
Reducing Docker alpine container size
find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .rundeps $runDeps \
&& apk del .build-deps
&& apk del build-base && rm -rf /var/cache/apk/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment