Skip to content

mount /var/lib/docker/image to host for image persistency on delete? #1459

Answered by jandubois
strobelight asked this question in Q&A
Discussion options

You must be logged in to vote

Finally got some time to actually test this, and here is a working version that persists both the root and user images on a separate volume:

$ grep -A 18 additionalDisk ~/.lima/docker/lima.yaml
additionalDisks:
- docker

provision:
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail

    MNT=/mnt/lima-docker
    ROOT=/var/lib/docker
    USER=/home/${LIMA_CIDATA_USER}.linux/.local/share/docker

    mkdir -p $MNT/root $MNT/user
    mkdir -p $ROOT $USER
    mount --bind /$MNT/root $ROOT
    mount --bind /$MNT/user $USER

    chown -R $LIMA_CIDATA_USER:$LIMA_CIDATA_USER $USER

$ limactl shell docker ls -l /mnt/lima-docker
total 24
drwx------  2 root root 16384 Apr  6 01:56 los…

Replies: 2 comments 22 replies

Comment options

You must be logged in to vote
13 replies
@AkihiroSuda
Comment options

@AkihiroSuda
Comment options

@afbjorklund
Comment options

@strobelight
Comment options

@jandubois
Comment options

Comment options

You must be logged in to vote
9 replies
@jandubois
Comment options

@jandubois
Comment options

Answer selected by strobelight
@strobelight
Comment options

@strobelight
Comment options

@jandubois
Comment options

@afbjorklund
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants