for-linux
for-linux copied to clipboard
Docker and Overlayroot on Ubuntu
Has anyone gotten overlayroot and docker to work together? I'm running Ubuntu 18.04.3LTS and docker daemon won't start up.
Specifically:
sudo apt-get install docker.io overlayroot
sudo docker ps #works, no errors.
Edit /etc/overlayroot.conf to change: overlayroot="" to overlayroot="tmpfs"
sudo update-initramfs -u
sudo reboot #to reboot into the read only overlay filesystem
sudo docker ps # Get the following error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ps: to remove the overlay filesystem do the following:
sudo overlayroot-chroot
Edit that same file to put it back to the original.
sudo update-initramfs -u
exit #to exit the chroot environment
sudo reboot #your system is back to a normal read/write Ubuntu system and "sudo docker ps" works again.
docker
Solved my own problem.
- Docker uses an overlay2 file system in /var/lib/docker.
- An overlay2 filesystem cannot be used on an overlay file system that overlayroot uses. It can however reside on it as regular files. So my solution was to:
- make a copy of /var/lib/docker/overlay2.
- Mount a tmpfs on /var/lib/docker/overlay2
- On boot - copy that copy of /var/lib/docker/overlay2 to that tmpfs.
- Start up docker. Docker now sees it on an tmpfs, not an overlay file system.
I'm running into issues with docker and overlayroot and I would love more detail on this solution;
- When you say 'mount a tmpfs on /var/lib/docker/overlay2' are you referring to overlayroot?
- I'm constrained to use aufs instead of overlay2, hoping a similar solution will work. If you have any tips or experience I'd love to hear it.
Thx!
Another solution might be using a different storage driver for docker. This can be configured in /etc/docker/daemon.json (see https://docs.docker.com/storage/storagedriver/select-storage-driver/)
I have tried fuse-overlayfs on top of my overlayroot, and it seems to work fine.