Skip to content

Instantly share code, notes, and snippets.

@fengye
Created September 7, 2018 23:52
Show Gist options
  • Save fengye/07e783797835de085dc17a7d748bd1f4 to your computer and use it in GitHub Desktop.
Save fengye/07e783797835de085dc17a7d748bd1f4 to your computer and use it in GitHub Desktop.
Docker Cheat Sheet

DOCKER CHEAT SHEET

List and Info

List locally stored static docker images

$ docker images

List running containers

$ docker ps

List running and stopped containers

$ docker ps -a

Running, Stopping and Deleting

Start an new container instance, make it terminal interactive, keeps the stopped container:

$ docker run -it IMAGE_ID

Start an new container instance, make it terminal interactive, and delete the stopped container after exiting:

$ docker run -it --rm IMAGE_ID

Resume stopped container(and attached to interactive terminal):

$ docker start -ai CONTAINER_ID

Delete a stopped container:

$ docker rm CONTAINER_ID

Delete ALL stopped container with sending SIGKILL:

$ docker rm -f docker ps -aq

Additional Running Options

Specifying a working directory:

$ docker run {-it --rm} -w=/MY/WORKING/DIRECTORY

Mapping local directory to container directory:

$ docker run {-it --rm} -v /LOCAL/DIR:/CONTAINER/DIR

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