Skip to content

Instantly share code, notes, and snippets.

@cloderic
Last active August 8, 2018 13:05
Show Gist options
  • Select an option

  • Save cloderic/6663a288d9830c82bf03 to your computer and use it in GitHub Desktop.

Select an option

Save cloderic/6663a288d9830c82bf03 to your computer and use it in GitHub Desktop.
Useful docker scripts

Docker Cheat Sheet

Images and Containers garbage collection

Just use Spotify's garbage collector by simply running

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock spotify/docker-gc

Check the build context for an image a.k.a check .dockerignore file

Create a Dockerfile.build-context file with the following content:

FROM alpine
RUN apk add tree
COPY . /build-context
WORKDIR /build-context
CMD tree

Then run the following

$ docker build -f Dockerfile.build-context -t build-context . && docker run --rm build-context

This will return a tree view of the build context sent to docker build, i.e. all the files NOT IGNORED by your .gitignore file.

Adapted from https://stackoverflow.com/a/40966234/454743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment