Copying files from Docker container to host

后端 未结 18 2395
小蘑菇
小蘑菇 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:03

    You do not need to use docker run.

    You can do it with docker create.

    From the docs:

    The docker create command creates a writeable container layer over the specified image and prepares it for running the specified command. The container ID is then printed to STDOUT. This is similar to docker run -d except the container is never started.

    So, you can do:

    docker create -ti --name dummy IMAGE_NAME bash
    docker cp dummy:/path/to/file /dest/to/file
    docker rm -f dummy
    

    Here, you never start the container. That looked beneficial to me.

提交回复
热议问题