How to copy files from host to Docker container?

前端 未结 30 2492
南方客
南方客 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:26

    The cleanest way is to mount a host directory on the container when starting the container:

    {host} docker run -v /path/to/hostdir:/mnt --name my_container my_image
    {host} docker exec -it my_container bash
    {container} cp /mnt/sourcefile /path/to/destfile
    

提交回复
热议问题