# find ID of your running container:docker ps
# create image (snapshot) from container filesystemdocker commit 12345678904b5 mysnapshot
# explore this filesystem using bash (for example)docker run -t -i mysnapshot /bin/bash
这样,您就可以在精确的时间时刻评估正在运行的容器的文件系统。容器仍在运行,不包括未来的更改。
您可以稍后使用(正在运行的容器的文件系统不受影响!)删除快照:
docker rmi mysnapshot
C)使用ssh
如果您需要持续访问,您可以将sshd安装到您的容器并运行sshd守护进程:
docker run -d -p 22 mysnapshot /usr/sbin/sshd -D
# you need to find out which port to connect:docker ps
docker create <image> # returns container ID the container is never started.docker cp <container ID>:<source_path> <destination_path>docker rm <container ID>cd <destination_path> && ls -lsah
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
Options:-d, --detach Detached mode: run command in the background--detach-keys string Override the key sequence for detaching acontainer-e, --env list Set environment variables-i, --interactive Keep STDIN open even if not attached--privileged Give extended privileges to the command-t, --tty Allocate a pseudo-TTY-u, --user string Username or UID (format:[:])-w, --workdir string Working directory inside the container
# find ID of your running container:
docker ps
# create image (snapshot) from container filesystem
docker commit 12345678904b5 mysnapshot
# explore this filesystem
docker run -t -i mysnapshot /bin/sh