Docker study notes-how to copy files from the docker container to the host

mission details

Through a dockerfile file, from obtaining dependencies to compiling and building, and finally packaging into a mirror. Now I want to save the built .jar file from the image in the above process and copy it to the host.

 

solve

You cannot save files directly from the image, but you can use the docker cp operation to copy the .jar file from the container . But note that when performing the docker cp operation, the container must be in the running state , and the newly created container and abnormal container operations cannot be performed, otherwise an error will be reported:

Error response from daemon: Container 3a2f0eb1610b5a456f3e522e35bcf8f6d2f2dc3b888170a23c401866d2b31b4b is not running

 

Docker operation

docker build -t docker_test:v1 .
docker run --name="container_test" docker_test:v1 .
docker exec container_test ls
docker cp container_test:/ldap.jar - > ./ldap.jar

Guess you like

Origin blog.csdn.net/qq_14997473/article/details/110482838