Copying files from Docker container to host

后端 未结 18 2379
小蘑菇
小蘑菇 2020-11-22 13:39

I\'m thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don\'t have to install all the runtimes and libraries on the agents

18条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 14:07

    Most of the answers do not indicate that the container must run before docker cp will work:

    docker build -t IMAGE_TAG .
    docker run -d IMAGE_TAG
    CONTAINER_ID=$(docker ps -alq)
    # If you do not know the exact file name, you'll need to run "ls"
    # FILE=$(docker exec CONTAINER_ID sh -c "ls /path/*.zip")
    docker cp $CONTAINER_ID:/path/to/file .
    docker stop $CONTAINER_ID
    

提交回复
热议问题