Processes only get locally persistent storage
How can containers be better?
They are even worse by default
Enter container:
docker run -it --workdir /src ubuntu
Inside container:
touch file.txt
ls -l
exit
Look for file in new instance:
docker run -it --workdir /src ubuntu
It’s gone!
Enter container with bind mount:
docker run -it --volume $PWD:/src --workdir /src ubuntu
Create file:
touch file.txt
ls –l
exit
Look for file in new instance:
docker run -it --volume $PWD:/src --workdir /src ubuntu
It’s alive!
Volume mounts are performed by daemon
Remote daemon will not see your local data
Prepare alternative Docker daemon:
docker run --name dind --detach \
--privileged \
--publish 127.0.0.1:2375:2375 \
docker:dind dockerd --host tcp://0.0.0.0:2375
docker context create dind \
--docker "host=tcp://127.0.0.1:2375"
Try to mount current directory
docker run -it --rm --volume "${PWD}:/src" --workdir /src alpine
Revert remote context
docker context use default
docker context rm dind
docker rm -f dind
Hard problem even for green field
NFS shares are a good option
Docker storage plugins connect to storage backends