INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / RSS / GPG

How to create docker volume from directory

№ 11114 В разделе Sysadmin от October 6th, 2020,
В подшивках: ,

Typically its not useful because you can directly mount directory to containers, but… who knows? May be you just want it.

For example, you have directory on your hard drive and want to move files inside docker volume:

root@boroda:/tmp/future-volume# find .

Just run move (or copy) command in busybox container:

docker run --rm -it \
    -v my-docker-volume:/destination \
    -v /tmp/future-volume:/source \
    busybox \
    /bin/sh -c "mv /source/* /destination/ && find /destination"

This command mounts (or create if not exists already) volume, mount directory on disk and move files from disk to volume.

After move completion you’ll see tree on moved files:


That’s all, easy.

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *


Облачная платформа

Fortune cookie: "...the only "right" a sodomite has in a Chrisian Theocracy is the right to die." [Dan Gentry, of Christian Research]