9951 explained code solutions for 126 technologies

dockerHow to extract file from docker image

In order to extract file from docker image, we will create temporary container, copy the file and then delete container.

docker run --name=tmp ubuntu
docker cp tmp:/etc/passwd /tmp
docker rm tmpctrl + c
docker run

launch container


set it's name to tmp


name of the image to create container from

docker cp

copy file from container to local machine


name of the container to copy from


file which we need to extract


local path to copy file to

docker rm tmp

remove tmp container