https://github.com/K0IN/docker-to-wsl Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + GitHub Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} K0IN / docker-to-wsl Public * Notifications You must be signed in to change notification settings * Fork 0 * Star 54 Build your own wsl distro in docker, based on this example: https:// gist.github.com/K0IN/485b6c9e442d10aa666c28672d621604 License MIT license 54 stars 0 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Discussions * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights K0IN/docker-to-wsl This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 18 Commits .gitattributes .gitattributes .gitignore .gitignore Dockerfile Dockerfile LICENSE LICENSE Readme.md Readme.md go.mod go.mod go.sum go.sum main.go main.go View all files Repository files navigation * README * MIT license Docker to WSL Docker to WSL is a tool that converts Docker images into WSL distributions. This project allows you to build or pull Docker images and then import them into WSL for further use. Why * Easily manage and replicate development environments across multiple systems * Avoid corrupting your main WSL distribution when testing or experimenting * Quickly start over with a fresh environment when needed * Leverage Docker's vast ecosystem of images for WSL use * Simplify the process of creating custom WSL distributions Features * Convert Docker images to WSL distributions * Build custom Docker images and import them as WSL distributions * Pull existing Docker images and convert them to WSL distributions * Launch newly created WSL distributions directly * Support for custom Dockerfiles and configurations Installation Dependencies This is a Windows only app. * Go 1.22 or later * Docker * WSL (Windows Subsystem for Linux) Steps go install github.com/k0in/docker-to-wsl/v2@main OR 1. Clone the repository: git clone https://github.com/K0IN/docker-to-wsl.git cd docker-to-wsl 2. Install the tool: go install Usage * --distro-name: Set the name for the new WSL distribution (required) * --image: Specify a Docker image to pull and convert or if a local file is specified, it will be built * --launch: Launch the new WSL distribution after creation * --help: Show help information Building and Importing a Dockerfile 1. Create a Dockerfile in your current directory. 2. Run the tool: docker-to-wsl --distro-name myDistro Pulling and Importing a Docker Image 1. Run the tool: docker-to-wsl --image --distro-name myDistro Launching the WSL Distribution 1. Add the --launch flag to the command: docker-to-wsl --image --distro-name myDistro --launch Dependencies and Licensing This project requires the following dependencies: * Docker * Opencontainers Image Spec * urfave/cli * yuk7/wsllib-go This project is licensed under the MIT License. See the LICENSE file for more information. Quick start Example Dockerfile (you can change this as you like): # example image FROM alpine:latest RUN apk update && apk add fish shadow RUN chsh -s /usr/bin/fish # Example add a env variable, Note: you cant use ENV RUN fish -c "set -Ux key value" # Example run a command on start up RUN printf "[boot]\ncommand = /etc/entrypoint.sh" >> /etc/wsl.conf RUN printf "#!/bin/sh\ntouch /root/booted" >> /etc/entrypoint.sh RUN chmod +x /etc/entrypoint.sh then run: docker-to-wsl --distro-name myDistro wsl -d myDistro Add your distro to the start menu (optional) Please fill in <> $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\.lnk") $Shortcut.TargetPath = "wsl.exe" $Shortcut.Arguments = "-d " $Shortcut.Save() Complex example Here is a full Dockerfile for a more complex setup FROM ubuntu:24.10 # basic setup RUN apt-get update && apt-get upgrade -y && apt-get install -y software-properties-common RUN apt update && apt install -y fish sudo curl RUN chsh -s /usr/bin/fish # setup user RUN useradd -m -s /usr/bin/fish -G sudo k0in # set password to 'k0in' RUN echo "k0in:k0in" | chpasswd k0in # confgure wsl RUN printf "[user]\ndefault=k0in" >> /etc/wsl.conf # ssh setup COPY --chown=k0in:k0in files/.ssh /home/k0in/.ssh RUN chmod 700 /home/k0in/.ssh RUN chmod 600 /home/k0in/.ssh/* # setup sudo RUN echo "k0in ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers # install packages RUN apt-get install -y wget git vim nano openssh-client clang gcc g++ make cmake gdb python3 python3-pip python3-venv # example you can use x11 apps :) RUN apt-get install -y x11-apps About Build your own wsl distro in docker, based on this example: https:// gist.github.com/K0IN/485b6c9e442d10aa666c28672d621604 Topics docker rootfs wsl2 wsl-distro Resources Readme License MIT license Activity Stars 54 stars Watchers 1 watching Forks 0 forks Report repository Releases No releases published Packages 0 No packages published Languages * Go 92.6% * Dockerfile 7.4% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.