Useful Docker commands

Useful docker commands

Cleaning up

PS > docker system prune
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N]

Stop and remove all containers

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Commit changes to container and showing history for an image

# Create a new image based on changes in a container
docker commit -m "installed git via apt-get" 57be
# Show history of an image
docker history 57be

Show container statistics

docker stats
CONTAINER ID        NAME                           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
8ef2426d3094        seleniumgriddocker_chrome_1    0.13%               100.5MiB / 1.952GiB   5.03%               553kB / 307kB       26.6MB / 4.1kB      32
c172345d5e47        seleniumgriddocker_firefox_1   0.16%               94.49MiB / 1.952GiB   4.73%               565kB / 307kB       20.7MB / 4.1kB      32
fe1de342578b        selenium-hub                   0.16%               131.2MiB / 1.952GiB   6.56%               617kB / 1.11MB      41MB / 4.1kB        31
comments powered by Disqus