Method for viewing files in docker image
- 2021-07-26 09:10:38
- OfStack
How do I view files in an docker image
1. If it is already running
For the already running image, we can view it through its ContrainerID
docker attach ContainerID
In this way, the corresponding container needs to be running and not in the stop state
2. If you do not run
For those that are not running, you can copy the files in the Docker image to the host. The command is indicated as follows:
docker cp < Container name > : < Path > < Host path >
Such as:
sudo docker cp nginx-ubuntu-container:/etc/apt/sources.list ~/Documents/
In this way, the corresponding container does not need to be running.
Content extension:
Copying files from the container to the host is the id of the container process
docker cp container process Id:/logs/temp./
Get the data from the host scp outside
scp remote_user@remoteIp:/logs.temp ./