What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Just some basic docker commands:

Guide

Manage images

List images

docker image ls

Remove images

Remove all dangling images (e.g. those that are not tagged or referenced by a container):

docker image prune

Remove all images not use by an existing container:

docker image prune -a

Manage containers

List containers

Show running:

docker container ls

Show all:

docker container ls --all

Start / stop / restart container

docker <start|stop|restart> <container>

Remove container

docker rm <container>

The below will stop and remove (delete) a container

docker rm -f <container>

List container port mappings 

docker port <container>

Copy file(s) from container to host

docker cp <container>:/file/path/within/container /host/path/target

Interactively log into container with bash

docker exec -it <container> /bin/bash

Cleaning

This will delete all stopped containers, all networks not used, all dangling images, and all build cache:

docker system prune

References

  1. https://docs.docker.com/
  2. https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host

  • No labels