Skip to content

Helpful Docker Commands

Shawn P. Serbin edited this page Jun 15, 2023 · 9 revisions

A few helpful commands for managing your Docker environment

Inspect your Docker images

e.g.

docker image inspect 5871e133549f

or to find out what architecture the image is built for

lee-169142:~ sserbin$ docker image inspect 5871e133549f | grep Architecture
        "Architecture": "arm64",

Cleanup environment

You can cleanup (prune) your environment to remove any images that are unused by taking up space on your computer

To cleanup unused images:

docker image prune

You can also remove specific images. E.g.
First do

docker image ls

Then identify the ID of the image to remove, e.g. 2bb301e6a312 Screen Shot 2022-10-06 at 1 30 12 PM

you can then delete by typing

docker image rm -f 2bb301e6a312

To cleanup old volumes:

docker volume prune

You can remove any containers you aren't using, however (warning!!) this would remove your ELM or Jupyter containers if not running:

docker container prune

You can cleanup everything at once using:

docker system prune

The docker system prune command is a shortcut that prunes images, containers, and networks. Volumes are not pruned by default, and you must specify the --volumes flag for docker system prune to prune volumes, e.g.

docker system prune --volumes

Save Docker images to tar or tar.gz files and re-load for .tar/.tar.gz archive file

https://docs.docker.com/engine/reference/commandline/save/


e.g. Save your local copy of the ELM Docker image to a tar file

docker save serbinsh/ngeearctic_elm_containers:elm_v2-for-ngee_multiarch > testdocker.tar

e.g. Save your local copy of the ELM Docker image to a tar.gz file

docker save serbinsh/ngeearctic_elm_containers:elm_v2-for-ngee_multiarch | gzip > testdocker.tar.gz

Load Docker image from file
https://docs.docker.com/engine/reference/commandline/load/


e.g. Reload from a tar.gz file

docker load < testdocker.tar.gz


Return to Home