[英]Copy a file to a Docker container just before starting it
I know that you can copy a file from host to a running Docker container using docker cp
, but in my case I want to copy it just before starting the docker container. 我知道您可以使用
docker cp
将文件从主机复制到正在运行的Docker容器,但就我而言,我想在启动Docker容器之前将其复制。 How can I do that? 我怎样才能做到这一点?
Note that I don't want this file in my built docker image, so I cannot copy it at build time even. 请注意,我不想在构建的docker映像中使用此文件,因此即使在构建时也无法复制该文件。 Another way is to use mounted volumes (with
-v
), but I don't want that either. 另一种方法是使用挂载的卷(与
-v
一起使用),但我也不希望这样。
you can do something like this: 您可以执行以下操作:
docker create mycon
docker cp /myfiles/file mycon:/path/file
docker start mycon
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.