Copy a file to a Docker container just before star

2020-04-20 06:47发布

问题:

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. 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. Another way is to use mounted volumes (with -v), but I don't want that either.

回答1:

you can do something like this:

docker create mycon
docker cp /myfiles/file mycon:/path/file
docker start mycon


标签: linux docker