Skip to content

Instantly share code, notes, and snippets.

View MacGyverBass's full-sized avatar
😀
Motivated

Steven Bass MacGyverBass

😀
Motivated
  • Ottawa Lake, MI, USA
View GitHub Profile
@MacGyverBass
MacGyverBass / My Docker Tips.md
Created October 17, 2020 17:35
My collection of tips for creating/organizing a Docker image

My Docker Tips

  1. When using alpine as a base image, use apk --no-cache add for packages... don't ever use apk update or apk upgrade — this just causes the repo database to be populated and add wasted space to an image. Additionally, if using Debian/Ubuntu, since you have to do a apt-get update first before installing, at the end of installation of packages, do a rm -rf /var/lib/apt/lists/* to clean up the apt lists.
  2. If you're going to add something for one step and never use it again, use && to merge the steps. For instance: apk --no-cache add git && git clone ${giturl} && apk --no-cache del git
  3. Combine steps, but don't just throw EVERYTHING on one RUN command. It's ugly. If you do combine steps, make use of \ at the end of a line and && at the beginning of the next line (preferably indented to line up to the commads) to keep things neat.
  4. If you have a weird sed -i "s/nothing.com/example.com/g" file.html line or similar that appears to do something that isn't a standard inst