Skip to content

Instantly share code, notes, and snippets.

@deoren
Last active February 26, 2018 05:51
Show Gist options
  • Save deoren/14b653c06e23489ac53cce0070361dca to your computer and use it in GitHub Desktop.
Save deoren/14b653c06e23489ac53cce0070361dca to your computer and use it in GitHub Desktop.
Docker scrarch notes - rough collection of details for a doc later on

Docker: Scratch notes

Concepts

  • "When you commit a container to an image, it will remember the last run parameters you used by default"

  • Dockerfile: "Each RUN instruction produces a new layer."

Commands

  • Last docker container: sudo docker ps -lq
  • List of docker container ids: sudo docker ps -qa
  • sudo docker rm $(sudo docker ps -a | grep -vE 'deoren|ID' | awk '{print $1}')

Last docker container: 

  sudo docker ps -lq

List of docker container ids: 

  sudo docker ps -qa

Prune all containers (but not images):

  sudo docker ps -aq | xargs sudo docker rm

What changed between the image and the last container that was run?

  sudo docker diff $(sudo docker -lq)

Saving changes made to a container as a new image (layer):

  sudo docker commit $(sudo docker ps -lq) DOCKER_PROFILE/DOCKER_REPO:TAG

Remove image:

  • sudo docker rmi IMAGE
  • sudo docker image rm IMAGE
@deoren
Copy link
Author

deoren commented Feb 26, 2018

As of the time this Gist entry was created, GitHub does not support notifications for comments for mentions to Gist entries (see isaacs/github#21 for details). Please contact me via Twitter or file an issue in the deoren/leave-feedback repo (created for that very purpose) if you wish to receive a response for your feedback. Thank you in advance!

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