Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rootfs persistence #80

Open
hansbogert opened this issue Apr 25, 2021 · 1 comment
Open

rootfs persistence #80

hansbogert opened this issue Apr 25, 2021 · 1 comment

Comments

@hansbogert
Copy link

what directories need to be made a (docker) volume, in order to make the configuration persistent?

@Rast1234
Copy link

Here's ideas i explored:

  • Mounting OverlayFS inside container, like OpenWrt does, is not a good idea because it requires escalating privileges for Docker.
  • Committing container as new image is possible but requires scripting around start/stop process and only could happen on container shutdown.
  • There is not much information about which folders in OpenWrt are crucial for backing up. So if you just persist /etc and /bin, something will break sooner or later.
  • Let's persist everything then! I copied all files from image to host and tried to mount that as /. Docker does not allow this unfortunately.
  • This is due to runtime-created directories like /run and /proc. My current workaround is that i mount everything copied from image as a separate volume.
  • Original OpenWrt container kinda loses its purpose after this, so i just use empty one with predefined CMD and ENV.

My Dockerfile and docker-compose:

FROM scratch
CMD /sbin/init
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
version: "3.9"
services:
  openwrt:
    container_name: openwrt
    # image built from above Dockerfile
    image: openwrt:empty
    # my network setup... replace with yours
    cap_add: [NET_ADMIN] 
    network_mode: none
    # mounting every folder from original container
    volumes:
      - /mnt/stuff/docker/openwrt/bin:/bin
      - /mnt/stuff/docker/openwrt/etc:/etc
      - /mnt/stuff/docker/openwrt/lib:/lib
      - /mnt/stuff/docker/openwrt/lib64:/lib64
      - /mnt/stuff/docker/openwrt/mnt:/mnt
      - /mnt/stuff/docker/openwrt/overlay:/overlay
      - /mnt/stuff/docker/openwrt/rom:/rom
      - /mnt/stuff/docker/openwrt/root:/root
      - /mnt/stuff/docker/openwrt/sbin:/sbin
      - /mnt/stuff/docker/openwrt/tmp:/tmp
      - /mnt/stuff/docker/openwrt/usr:/usr
      - /mnt/stuff/docker/openwrt/var:/var
      - /mnt/stuff/docker/openwrt/www:/www

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants