{"id":13510436,"url":"https://github.com/iximiuz/docker-to-linux","last_synced_at":"2025-04-04T12:08:38.767Z","repository":{"id":35902981,"uuid":"189901121","full_name":"iximiuz/docker-to-linux","owner":"iximiuz","description":"Make bootable Linux disk image (ab)using Docker","archived":false,"fork":false,"pushed_at":"2023-01-02T19:18:57.000Z","size":25,"stargazers_count":685,"open_issues_count":11,"forks_count":97,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-28T11:09:19.845Z","etag":null,"topics":["bootloader","docker","linux","linux-kernel","virtual-machine"],"latest_commit_sha":null,"homepage":"https://iximiuz.com/en/posts/from-docker-container-to-bootable-linux-disk-image/","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iximiuz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-02T22:23:57.000Z","updated_at":"2025-03-27T21:53:58.000Z","dependencies_parsed_at":"2023-01-16T08:56:58.657Z","dependency_job_id":null,"html_url":"https://github.com/iximiuz/docker-to-linux","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iximiuz%2Fdocker-to-linux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iximiuz%2Fdocker-to-linux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iximiuz%2Fdocker-to-linux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iximiuz%2Fdocker-to-linux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iximiuz","download_url":"https://codeload.github.com/iximiuz/docker-to-linux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174423,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootloader","docker","linux","linux-kernel","virtual-machine"],"created_at":"2024-08-01T02:01:38.927Z","updated_at":"2025-04-04T12:08:38.751Z","avatar_url":"https://github.com/iximiuz.png","language":"Makefile","readme":"# docker-to-linux - make bootable Linux disk image abusing Docker\n\n```diff\n! Support development of this project \u003e patreon.com/iximiuz\n```\n\nThere is no real goal behind this project. Just out of my curiosity what if:\n\n  - launch a base Linux container (debian, alpine, etc)\n  - pull in Linux kernel \u0026 init system (systemd, OpenRC, etc)\n  - dump container's filesystem to a disk image\n  - install bootloader (syslinux) to this image...\n\nThen it should be probably possible to launch a ~~real~~ virtual machine with such an image!\n\nTry it out:\n\n```bash\n# 1. Build the image.\n#    Depending on your setup, you may need to preceed `make` with `sudo`.\nmake debian  # or ubuntu, or alpine\n\n# 2. Run it! Use username `root` and password `root` to log in.\nqemu-system-x86_64 -drive file=debian.img,index=0,media=disk,format=raw -m 4096\n# 2. Alternate\nqemu-system-x86_64 -hda debian.qcow2 -m 512\n\n# 3. Clean up when you are done.\nmake clean\n```\n\nIt works!\n\nYou can increase or decrease the size of the VM hard disk via the environment variable VM_DISK_SIZE_MB (1024 by default).  \nFor example for a 3GB disk:\n\n```\nmake debian VM_DISK_SIZE_MB=3072  # or ubuntu, or alpine\n```\n\nCheck out `Makefile` for more details or read my article on \u003ca href=\"https://iximiuz.com/en/posts/from-docker-container-to-bootable-linux-disk-image/\"\u003eiximiuz.com\u003c/a\u003e.\n\n## Features\n- Real quick build a bootable Linux image with a single command!\n- 3 target distributives: Ubuntu 20.04, Debian Bullseye, Alpine 3.13.5\n- Build from macOS (including M1 chips) or Linux hosts\n\n## FAQ\n- Q: I'm getting an error about \"read-only filesystem\". How can I make it writable?\n\n  A: It's Linux default behaviour to mount the / filesystem as read-only. You can always remount it with `mount -o remount,rw /`.\n\n- Q: How can I access network from the VM / How can I SSH into the VM?\n\n  A: Networking is not configured at the moment. If you want to configure it yourself, search for TUN/TAP/bridge devices. Don't forget to open a PR if you come up with a working solution.\n\n\n## Release notes\n#### 2021-05-24\n- Start using ext4 instead of ext3.\n\n#### 2021-05-07\n- Fix - Ubuntu 20.04 stopped working because of the changed path to vmlinuz and initrd files.\n\n#### 2021-05-02\n- Fix macOS support [#10](https://github.com/iximiuz/docker-to-linux/issues/10) (thanks to @xavigonzalvo for reporting and suggesting the fix)\n  - move `losetup` call from Makefile to the builder container\n  - explicitly select amd64 architecture in target distr Dockerfiles to support builds on ARM hosts (_aka_ M1)\n- Upgrade target distr versions\n  - Ubuntu 18.04 -\u003e 20.04\n  - Debian Stretch -\u003e Bullseye\n  - Alpine 3.9.4 -\u003e 3.13.5\n\n#### 2020-02-29\n- Improve Alpine support [#7](https://github.com/iximiuz/docker-to-linux/pull/7) (creds @monperrus)\n\n#### 2019-08-02\n- Fix loopback device lookup [#3](https://github.com/iximiuz/docker-to-linux/pull/3) (creds @christau)\n\n#### 2019-06-03\n- Initial release\n\n## TODO\n- add basic networking support\n- support different image formats (e.g. VirtualBox VDI)\n- support different target architectures (e.g. ARM)\n\n## Similar projects\n\n...or tangential projects relying on the similar technique:\n\n- [firecracker-microvm/firecracker](https://github.com/firecracker-microvm/firecracker/blob/d2c52b882ced88be581eed4f4a804ffba5a1be86/docs/rootfs-and-kernel-setup.md) suggests a similar trick to build custom VM rootfs images.\n- [weaveworks/ignite](https://github.com/weaveworks/ignite/blob/e3766643ffa88ad1d98d0cb40043cd1f94b4632a/images/Makefile) actually uses the same technique to build Firecracker VM images.\n- [d2vm (Docker to Virtual Machine)](https://github.com/linka-cloud/d2vm) a CLI tool (written in Go) to build virtual machine images from Docker images (inspired by the docker-to-linux project).\n","funding_links":[],"categories":["Makefile","linux"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiximiuz%2Fdocker-to-linux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiximiuz%2Fdocker-to-linux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiximiuz%2Fdocker-to-linux/lists"}