Skip to content

Instantly share code, notes, and snippets.

@gbraad
Last active May 15, 2026 11:17
Show Gist options
  • Select an option

  • Save gbraad/861e322b794a011444a33262a256be6e to your computer and use it in GitHub Desktop.

Select an option

Save gbraad/861e322b794a011444a33262a256be6e to your computer and use it in GitHub Desktop.
Import devenv image into container runtime

Import devenv WSL image into container runtime

Note

This will describe in short how to get your old wsl environment running in a container runtime, such as containerd or Podman. While it is possible to use vhdx, I had better results with tarballs. A vhdx needs to be converted, use qemy-nbd etc, as you can not boot this as a VM unless you install the kernel and modules.

Prepare WSL export

Prepare the distribution for export, such as removing large files, unnecessary mountpoints, symlinks, etc. After this

 wsl --export dotfedora D:\Backups\dotfedora-260513.tar.gz --format tar.gz

Prepare Podman

With two prerequisites in place beforehand

~/.config/containers/containers.conf:

[engine]
image_copy_tmp_dir="/home/gbraad/podman-import-tmp"

This is needed to prevent copying/moving the image from a primary disk to an external/different disk, or in my case, running out of space on /var.

/etc/subuid and /etc/subgid:

sudo sed -i 's/gbraad:100000:65536/gbraad:100000:1000000/' /etc/subuid /etc/subgid
podman system migrate

otherwise issues for the user can occur, as WSL uses ver high numbered users and groups.

Perform import

Sit back and grab a cup of coffee as thks can take long. Or better, do something else ...

nohup bash -c 'zcat /home/gbraad/dotfedora-260513.tar.gz | podman import - wslimport-backup:260513'

We use nohup to prevent issues that will stop the import, like a disconnected ssh session

Prepare for use

Then prepare to run with systemd. These mountpoints are specific to my image, so make sure to make changes.

FROM localhost/wslimport-backup:260513

RUN rm -f /home/gbraad/Projects /home/gbraad/Documents /home/gbraad/Downloads                   \
          /home/gbraad/Music /home/gbraad/Videos /home/gbraad/Pictures                          \
    && mkdir -p /home/gbraad/Projects /home/gbraad/Documents /home/gbraad/Downloads             \
          /var/home/gbraad/Projects /var/home/gbraad/Documents /var/home/gbraad/Downloads

# Run with systemd
CMD ["/sbin/init"]

Build image

podman build -f Containerfile -t localhost/wslimport-backup:latest

Run image

Run your image with distrobox or podman with the right mountpoints setup. In my case:

dev wslbackup from-image ...

Ref: https://github.com/gbraad-dotfiles/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment