What is the right way to add data to an existing named volume in Docker?

后端 未结 4 824
感情败类
感情败类 2020-11-29 16:43

I was using Docker in the old way, with a volume container:

docker run -d --name jenkins-data jenkins:tag echo \"data-only container for Jenkins\"

4条回答
  •  一整个雨季
    2020-11-29 17:26

    Here are steps for copying contents of ~/data to docker volume named my-vol

    Step 1. Attach the volume to a "temporary" container. For that run in terminal this command :

    docker run --rm -it --name alpine --mount type=volume,source=my-vol,target=/data alpine

    Step 2. Copy contents of ~/data into my-vol . For that run this commands in new terminal window :

    cd ~/data docker cp . alpine:/data

    This will copy contents of ~/data into my-vol volume. After copy exit the temporary container.

提交回复
热议问题