Useful Docker Commands Docker cheatsheet - Davz33/tutorials GitHub Wiki

Docker Logo. This logo belongs to Docker Inc., which own all attached legal rights.
This logo belongs to Docker Inc., which owns all legal rights thereof.

Docker Containers

List active docker containers

docker ps

List all docker containers

docker ps -a

Rename container

docker rename oldname newname

Pause docker container

docker container pause <container ID or NAME>

Run docker container detached and interactively

docker run -it -d author/dockername /bin/bash
Note the -d option, which stands for detached: this means that the command you run the container with (/bin/bash), will run in the background so that the container will live through the termination of the current shell session.

Ssh into a running linux docker container

docker exec -ti <name of the container> /bin/bash

Stop a docker container

warning: make sure to save configurations and apps you'll need again before stopping your container.
You should have either

  • stored those on container locations mapped to host via volumes flags (-v path:path)
  • saved the entire state of the container to a docker image via docker commit

docker container stop <container ID or NAME>

Docker Images

List docker images

docker image ls

Rename docker image

docker tag OldName:tag NewName:tag

Docker Volumes, Docker Mounts

List volume in Docker containers

  • List containers first
    docker ps
  • Take note of the container id , then :
    docker inspect -f '{{ .Mounts }}' containerid
⚠️ **GitHub.com Fallback** ⚠️