How to copy files from host to Docker container?

前端 未结 30 3131
南方客
南方客 2020-11-22 06:58

I am trying to build a backup and restore solution for the Docker containers that we work with.

I have Docker base image that I have created, ubuntu:base

30条回答
  •  梦谈多话
    2020-11-22 07:32

    My favorite method:

    CONTAINERS:

    CONTAINER_ID=$(docker ps | grep  | awk '{ print $1 }' | xargs docker inspect -f '{{.Id}}')
    

    file.txt

    mv -f file.txt /var/lib/docker/devicemapper/mnt/$CONTAINER_ID/rootfs/root/file.txt
    

    or

    mv -f file.txt /var/lib/docker/aufs/mnt/$CONTAINER_ID/rootfs/root/file.txt
    

提交回复
热议问题