Copy or scp files to /var/lib/boot2docker for boot2docker VM managed by docker-machine
To use Docker on OS X, I’m using a boot2docker VM running in VirtualBox, managed by docker-machine. The boot2docker documents mention a persistence volume
/var/lib/boot2docker. I would like to copy a file
bootlocal.sh on the host filesystem over to the boot2docker VM.
I thought that docker-machine’s
scp command would work for this,
docker-machine scp bootlocal.sh dockerhost:/var/lib/boot2docker/
Unfortunately, this gives
scp: /var/lib/boot2docker/bootlocal.sh: Permission denied exit status 1
Checking the file permissions, we can see that
root is the only one with write permissions to this directory, by default:
docker@dockerhost:~$ ll -d /var/lib/boot2docker lrwxrwxrwx 1 root root 29 May 31 17:40 /var/lib/boot2docker -> /mnt/sda1/var/lib/boot2docker/ docker@dockerhost:~$ ll -d /mnt/sda1/var/lib/boot2docker drwxr-xr-x 6 root root 4096 May 31 17:40 /mnt/sda1/var/lib/boot2docker/
It is not possible to specify the user
root as the one to use with
How does one copy files to
/var/lib/boot2docker, preferably from the host machine?
One Solution collect form web for “Copy or scp files to /var/lib/boot2docker for boot2docker VM managed by docker-machine”
I could not find a way to do this using
docker-machine scp. I did discover that, at least for OS X, the
/Users directory of the host machine is mounted as a volume in the docker-machine VM, meaning that if the file is within the host file system under that directory, the VM can access it verbatim.
Knowing this, my workaround was to use
docker-machine ssh to issue a
cp command for the files I needed transferred.
docker-machine ssh dockerhost sudo cp /Users/username/path/to/bootlocal.sh /var/lib/boot2docker/