Skip to main content

Administration : commandes utiles

Les commandes ci-dessous sont directement copiées depuis la documentation de docker :
 🔗 https://docs.docker.com/reference/cli/docker/

Les usages principaux des commandes ont déjà été abordés jusqu'ici.

docker image

Command Description
docker image history Show the history of an image
docker image import Import the contents from a tarball to create a filesystem image
docker image inspect Display detailed information on one or more images
docker image load Load an image from a tar archive or STDIN
docker image ls List images
docker image prune Remove unused images
docker image pull Download an image from a registry
docker image push Upload an image to a registry
docker image rm Remove one or more images
docker image save Save one or more images to a tar archive (streamed to STDOUT by default)
docker image tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
debian@debian:~$ docker image inspect ubuntu
[
    {
        "Id": "sha256:e0f16e6366fef4e695b9f8788819849d265cde40eb84300c0147a6e5261d2750",
        "RepoTags": [
            "ubuntu:24.04",
            "ubuntu:latest"
        ],
        "RepoDigests": [
            "ubuntu@sha256:7c06e91f61fa88c08cc74f7e1b7c69ae24910d745357e0dfe1d2c0322aaf20f9"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2025-07-30T06:51:03.091147588Z",
        "DockerVersion": "24.0.7",
        "Author": "",
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 78122494,
        "GraphDriver": {
            "Data": {
                "MergedDir": "/var/lib/docker/overlay2/8a59ab09262cee8d6004dcd5b978cd668baae2521d83a0621e5d1366fbd864a1/merged",
                "UpperDir": "/var/lib/docker/overlay2/8a59ab09262cee8d6004dcd5b978cd668baae2521d83a0621e5d1366fbd864a1/diff",
                "WorkDir": "/var/lib/docker/overlay2/8a59ab09262cee8d6004dcd5b978cd668baae2521d83a0621e5d1366fbd864a1/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:cd9664b1462ea111a41bdadf65ce077582cdc77e28683a4f6996dd03afcc56f5"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        },
        "Config": {
            "Cmd": [
                "/bin/bash"
            ],
            "Entrypoint": null,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Labels": {
                "org.opencontainers.image.ref.name": "ubuntu",
                "org.opencontainers.image.version": "24.04"
            },
            "OnBuild": null,
            "User": "",
            "Volumes": null,
            "WorkingDir": ""
        }
    }
]

docker container

Command Description
docker container attach Attach local standard input, output, and error streams to a running container
docker container commit Create a new image from a container's changes
docker container cp Copy files/folders between a container and the local filesystem
docker container create Create a new container
docker container diff Inspect changes to files or directories on a container's filesystem
docker container exec Execute a command in a running container
docker container export Export a container's filesystem as a tar archive
docker container inspect Display detailed information on one or more containers
docker container kill Kill one or more running containers
docker container logs Fetch the logs of a container
docker container ls List containers
docker container pause Pause all processes within one or more containers
docker container port List port mappings or a specific mapping for the container
docker container prune Remove all stopped containers
docker container rename Rename a container
docker container restart Restart one or more containers
docker container rm Remove one or more containers
docker container run Create and run a new container from an image
docker container start Start one or more stopped containers
docker container stats Display a live stream of container(s) resource usage statistics
docker container stop Stop one or more running containers
docker container top Display the running processes of a container
docker container unpause Unpause all processes within one or more containers
docker container update Update configuration of one or more containers
docker container wait Block until one or more containers stop, then print their exit codes

debian@debian:~$ docker inspect c5
[
    {
        "Id": "f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158",
        "Created": "2025-08-29T20:35:19.745912071Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 3405,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2025-08-29T20:35:19.948819333Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:e0f16e6366fef4e695b9f8788819849d265cde40eb84300c0147a6e5261d2750",
        "ResolvConfPath": "/var/lib/docker/containers/f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158/hostname",
        "HostsPath": "/var/lib/docker/containers/f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158/hosts",
        "LogPath": "/var/lib/docker/containers/f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158/f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158-json.log",
        "Name": "/c5",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "bridge",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "ConsoleSize": [
                54,
                235
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "private",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": [],
            "BlkioDeviceWriteBps": [],
            "BlkioDeviceReadIOps": [],
            "BlkioDeviceWriteIOps": [],
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": null,
            "PidsLimit": null,
            "Ulimits": [],
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/interrupts",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware",
                "/sys/devices/virtual/powercap"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "ID": "f5f93155c9e02fc6a56d40b6d1bf5d0f3cd5c73106c72882f8878038398fe158",
                "LowerDir": "/var/lib/docker/overlay2/9c831cc72a1726631cb4c9e776e29e8192a4793b9172c2fabf2226fdfb8babb9-init/diff:/var/lib/docker/overlay2/8a59ab09262cee8d6004dcd5b978cd668baae2521d83a0621e5d1366fbd864a1/diff",
                "MergedDir": "/var/lib/docker/overlay2/9c831cc72a1726631cb4c9e776e29e8192a4793b9172c2fabf2226fdfb8babb9/merged",
                "UpperDir": "/var/lib/docker/overlay2/9c831cc72a1726631cb4c9e776e29e8192a4793b9172c2fabf2226fdfb8babb9/diff",
                "WorkDir": "/var/lib/docker/overlay2/9c831cc72a1726631cb4c9e776e29e8192a4793b9172c2fabf2226fdfb8babb9/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "f5f93155c9e0",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "ubuntu",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.opencontainers.image.ref.name": "ubuntu",
                "org.opencontainers.image.version": "24.04"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "34132282ba3e544d46aec112f27ed949a571b114ebc2fee664fc034776e06be7",
            "SandboxKey": "/var/run/docker/netns/34132282ba3e",
            "Ports": {},
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "c239ab855b930537d28d6ebe5343f7eb9241eca8c7e086fe9894aa19c5f7cce7",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "56:4e:03:5c:c5:d4",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "MacAddress": "56:4e:03:5c:c5:d4",
                    "DriverOpts": null,
                    "GwPriority": 0,
                    "NetworkID": "e5ee2347d56211a8f10602c4ebc07b27a15b2f9507af47f3c7c16bdbcf18fc6c",
                    "EndpointID": "c239ab855b930537d28d6ebe5343f7eb9241eca8c7e086fe9894aa19c5f7cce7",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DNSNames": null
                },
                "reseau2": {
                    "IPAMConfig": {},
                    "Links": null,
                    "Aliases": [],
                    "MacAddress": "5a:76:dd:aa:62:15",
                    "DriverOpts": {},
                    "GwPriority": 0,
                    "NetworkID": "562ad4a6e8b3105f619bd0deb30b89d5aaddde71babd6422ad912ccfa327687d",
                    "EndpointID": "f71251f1d3c4d9be09376f687898d22a984017b91f6da6c8fe75fa65dedba007",
                    "Gateway": "172.19.0.1",
                    "IPAddress": "172.19.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DNSNames": [
                        "c5",
                        "f5f93155c9e0"
                    ]
                }
            }
        }
    }
]

docker volume

Command Description
docker volume create Create a volume
docker volume inspect Display detailed information on one or more volumes
docker volume ls List volumes
docker volume prune Remove unused local volumes
docker volume rm Remove one or more volumes
docker volume update Update a volume (cluster volumes only)

image.png

docker network

Command Description
docker network connect Connect a container to a network
docker network create Create a network
docker network disconnect Disconnect a container from a network
docker network inspect Display detailed information on one or more networks
docker network ls List networks
docker network prune Remove all unused networks
docker network rm Remove one or more networks

image.png

docker stats

La commande docker stats affiche les informations essentielles des conteneurs actuellement lancés. Par défaut, la commande s'actualise toutes les 2 secondes.

image.png

docker system

Command Description
docker system df Show docker disk usage
docker system events Get real time events from the server
docker system info Display system-wide information
docker system prune Remove unused data

image.png