Skip to main content

Commands


Get Container

Running Containers
docker ps
All Containers
docker ps -a

Inspect Container

docker inspect foo

Get Tail Logs

docker logs --tail 100 xxx

Get Mounts Info

docker inspect foo | grep -A 10 -i mounts
"Mounts": [
    {
        "Type": "bind",
        "Source": "xxx",
        "Destination": "xxx",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
    }
]

Get Volumes

docker volume ls
DRIVER  VOLUME NAME
local   0c9658033cba5db4652849467b9ace2ad40e74db5c160fccef0100180f145a13
local   0c82598530ad71b395a903130296f0689ea6b7fcb15a6c00fd8f8bdf2e712731

Get IP Info

docker inspect foo | grep -A 15 Networks
docker inspect container | grep '"IPAddress"'
docker inspect --format '{{ .NetworkSettings.IPAddress }}' container

Stats Container

docker stats foo

Inspect Images Manifests

docker buildx imagetools inspect registry.example.com/ops-center:130
Name:      registry.example.com/ops-center:130
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
Digest:    sha256:061206dc29d6d99cd254fda889a6157c66908d85ddb0d2d6a371af92a91ba11d

Manifests:
  Name:      registry.example.com/ops-center:130@sha256:71ee0534f747600ae6b3d864d6645b85e8f8cd85ea7b27d3469f58c2ac9a0262
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/amd64

  Name:      registry.example.com/ops-center:130@sha256:cfb7de94eb9db1c950a2892367fb740a07e921e360fe5dc684d7bb8fd5ad69b3
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/arm64

Container Restart Setting

Set restart=no means no auto start when Docker Desktop or OrbStarck launch.

docker update --restart=no <container_name_or_id>

Resource Limit

docker update --cpus=1 --memory=6g --memory-swap=6g gitlab
docker inspect gitlab | grep -iE "memory|nano"
docker stats gitlab
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O           BLOCK I/O        PIDS
1caec014950e   gitlab    46.86%    5.618GiB / 6GiB     93.64%    6.59GB / 22.8GB   2.36TB / 236GB   388