Is there a way to inspect a running Docker container? Eg, inspect the filesystem using a shell, etc?
To inspect an image, we could using docker run <tag> /bin/bash
but I am looking to inspect a running container, not an image.
note that docker container inspect
is not what I am looking for - that command just gives me metadata about the container.
您可以使用docker exec命令
docker exec -it {container Id or name} command
Assuming that your container has a typical filesystem, you can just use docker exec
to start a shell inside the container, as in:
docker exec -it mycontainer bash
Or if bash
isn't available (for example, Alpine-based images):
docker exec -it mycontainer sh
Alternatively, you can export a container's filesystem as a tar
archive using docker export
. For example:
docker export -o mycontainer.tar mycontainer
And then you can inspect the archive or extract it as necessary. If you just want to a file listing, then:
docker export mycontainer | tar tf -
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.