Since it can not be extracted directly from the image, start the container as follows and copy it with docker cp
CONTAINER_ID=`docker create $IMAGE_NAME`
docker cp $CONTAINER_ID:$FILEPATH .
You may want to retrieve the source code or files in an Image that you have deployed for bugs or spec investigation. I have summarized the procedure of what to do at that time.
All you need to know is the path to the target file or directory, but if not, you'll need to look inside to find what you're looking for.
It should contain / bin / bash and / bin / sh, so use it to find files interactively.
docker run --rm -it $IMAGE_NAME /bin/bash
If it is not included, you can use it as the base image of the Dockerfile and create an installed image.
You can see the file tree for each layer by using dive.
If you know that it was added in a particular layer, you may find it faster.
dive $IMAGE_NAME
The following article will be helpful for how to use dive. https://qiita.com/t_o_d/items/625ad7a274ca34be3312
It seems that files cannot be extracted directly from the image.
Therefore, you can copy the files and folders by starting the container and copying with docker cp
as shown below.
# IMAGE_Set the target image name in NAME and the file path in the Docker Image of the target file in FILEPATH.
IMAGE_NAME=me/my_application:1.0.0
FILEPATH=/app/scripts/woker/
CONTAINER_ID=`docker create $IMAGE_NAME`
docker cp $CONTAINER_ID:$FILEPATH .
docker rm $CONTAINER_ID
Recommended Posts