Copying files from Docker container to host

后端 未结 18 2240
小蘑菇
小蘑菇 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 13:57

    In order to copy a file from a container to the host, you can use the command

    docker cp :/file/path/within/container /host/path/target
    

    Here's an example:

    $ sudo docker cp goofy_roentgen:/out_read.jpg .
    

    Here goofy_roentgen is the container name I got from the following command:

    $ sudo docker ps
    
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES
    1b4ad9311e93        bamos/openface      "/bin/bash"         33 minutes ago      Up 33 minutes       0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp   goofy_roentgen
    

    You can also use (part of) the Container ID. The following command is equivalent to the first

    $ sudo docker cp 1b4a:/out_read.jpg .
    

提交回复
热议问题