深度阅读

How to copy files to and from a Docker container?

作者
作者
2023年08月22日
更新时间
8.05 分钟
阅读时间
0
阅读量

To copy files to and from a Docker container, you can use the docker cp command followed by the source path on the host machine and the destination path within the container, or vice versa. For example, to copy a file from the host machine to a running container called my_container, you can use the following command:

docker cp foo.txt my_container:/bar/foo.txt

This will copy the local file foo.txt to the container’s /bar directory as foo.txt. Similarly, to copy a file from a container to the host machine, you can use the command:

docker cp my_container:/bar/foo.txt foo.txt

This will copy the file foo.txt from the container’s /bar directory to the current directory on the host machine. For more information, refer to the Docker documentation on docker cp.

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。