Docker: Difference between revisions

From DWIKI
 
(3 intermediate revisions by the same user not shown)
Line 9: Line 9:
*[https://training.play-with-docker.com/beginner-linux/ Docker for beginners]
*[https://training.play-with-docker.com/beginner-linux/ Docker for beginners]
*[https://runnable.com/docker/basic-docker-networking Docker networking]
*[https://runnable.com/docker/basic-docker-networking Docker networking]
*[https://docs.docker.com/config/pruning/ Docker pruning]


=HOWTO=
=HOWTO=
Line 18: Line 19:
  docker ps -a
  docker ps -a


==Show disk usage==
docker system df
outputs:
TYPE            TOTAL    ACTIVE    SIZE      RECLAIMABLE
Images          27        10        11.35GB  5.72GB (50%)
Containers      12        12        123.6MB  0B (0%)
Local Volumes  0        0        0B        0B
Build Cache    0        0        0B        0B
===RECLAIMABLE===
Is what you get back when running
docker prune -a


==List images==
==List images==
Line 55: Line 67:


=FAQ=
=FAQ=
==The container name "/mycontainer" is already in use by container==
It already exists, so use
docker start
instead of
docker run
==Compose==
===docker: 'compose' is not a docker command.===
apt install docker-compose
===unknown flag: --detach===
apt install docker-compose-v2

Latest revision as of 16:23, 8 April 2024

Links


Docs

HOWTO

List running containers

docker ps

List containers

docker ps -a

Show disk usage

docker system df

outputs:

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          27        10        11.35GB   5.72GB (50%)
Containers      12        12        123.6MB   0B (0%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B

RECLAIMABLE

Is what you get back when running

docker prune -a

List images

docker images

Get shell in running container

To get image name

docker ps

then

docker exec -it <image-id> bash

Network

docker network ls
docker network inspect


image has dependent child images

docker inspect --format='Template:.Id Template:.Parent' $(docker images --filter since=<image_id> -q)

Dangling images

list dangling images

docker images -f dangling=true

Remove dangling image

docker rmi image-id

Remove all dangling images

docker rmi $(docker images -f dangling=true -q)

image is being used by stopped container xyz

docker rm xyz

and try again


Backups

FAQ

The container name "/mycontainer" is already in use by container

It already exists, so use

docker start

instead of

docker run

Compose

docker: 'compose' is not a docker command.

apt install docker-compose

unknown flag: --detach

apt install docker-compose-v2