{"id":15650382,"url":"https://github.com/madworx/docker-netbsd","last_synced_at":"2025-04-09T21:20:45.267Z","repository":{"id":51206666,"uuid":"139155158","full_name":"madworx/docker-netbsd","owner":"madworx","description":"QEMU-based NetBSD docker images","archived":false,"fork":false,"pushed_at":"2024-11-27T17:59:14.000Z","size":230,"stargazers_count":61,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T19:07:53.444Z","etag":null,"topics":["docker","docker-image","netbsd","qemu","travis-ci"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madworx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-29T13:50:58.000Z","updated_at":"2025-02-01T16:52:59.000Z","dependencies_parsed_at":"2024-10-23T01:48:34.564Z","dependency_job_id":"ad1170ca-0699-4c1e-9c52-847d35859bd5","html_url":"https://github.com/madworx/docker-netbsd","commit_stats":{"total_commits":65,"total_committers":5,"mean_commits":13.0,"dds":0.4769230769230769,"last_synced_commit":"43c6f260b16326e58954843e9b2fc57dea98f3ad"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madworx%2Fdocker-netbsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madworx%2Fdocker-netbsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madworx%2Fdocker-netbsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madworx%2Fdocker-netbsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madworx","download_url":"https://codeload.github.com/madworx/docker-netbsd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112362,"owners_count":21049645,"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":["docker","docker-image","netbsd","qemu","travis-ci"],"created_at":"2024-10-03T12:34:24.647Z","updated_at":"2025-04-09T21:20:45.249Z","avatar_url":"https://github.com/madworx.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/madworx/docker-netbsd.svg?branch=master)](https://travis-ci.org/madworx/docker-netbsd)\n\n# QEMU-based NetBSD docker images\n\nRun NetBSD in a docker container (Emulated/virtualized x86_64 using QEMU).\n\nAll images have KVM-enabled QEMU, which  will be enabled if the docker\nengine supports it and you are running the container with `--device=/dev/kvm`.\n\nAvailable at Docker hub as [madworx/netbsd](https://hub.docker.com/r/madworx/netbsd/).\n\n## Usage\n\n### Quickstart\n\n#### Start an \"interactive\" session on the NetBSD console\n\n(Quite useful if you're just testing the container, or doing kernel development)\n\n```shell\n$ docker run --device=/dev/kvm -it madworx/netbsd\nSeaBIOS (version rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org)\niPXE (http://ipxe.org) 00:02.0 C000 PCI2.10 PnP PMM+1FF91300+1FEF1300 C000\n...\npxeboot_ia32_com0.bin : 73952 bytes [PXE-NBP\n\u003e\u003e NetBSD/x86 PXE boot, Revision 5.1 (Thu Aug  4 15:30:37 UTC 2022) (from NetBSD 9.3)\n\u003e\u003e Memory: 625/522104 k\nPress return to boot now, any other key for boot menu\nbooting netbsd - starting in 0 seconds.\n...\nSee /var/run/rc.log for more information.\nTue Sep 27 14:24:27 UTC 2022\n\nNetBSD/amd64 (netbsd) (constty)\n\nlogin: root\nSep 27 14:24:48 netbsd login: ROOT LOGIN (root) on tty constty\nCopyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,\n    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,\n    2018, 2019, 2020, 2021, 2022\n    The NetBSD Foundation, Inc.  All rights reserved.\nCopyright (c) 1982, 1986, 1989, 1991, 1993\n    The Regents of the University of California.  All rights reserved.\n\nNetBSD 9.99.100 (GENERIC) #39: Tue Sep 27 14:35:15 CEST 2022\n\nWelcome to NetBSD!\n\nWe recommend that you create a non-root account and use su(1) for root access.\nnetbsd# id\nuid=0(root) gid=0(wheel) groups=0(wheel),2(kmem),3(sys),4(tty),5(operator),20(staff),31(guest),34(nvmm)\n```\n\n### Available environment variables\n\n#### `USER_ID`, `USER_NAME`\n\nIf these environment variables are set, the container will create a user with the provided uid and username. \n(The specified user will be added to the `wheel` group.)\n\nThis is useful if you're mounting your home directory into the container; Provided that you have your public SSH key in `~/.ssh/authorized_keys`, the following example will work:\n\n```shell\n$ pwd\n/home/mad\n$ echo \"Hello, World.\" \u003e foobar.txt\n$ docker run \\\n    -d --rm --device=/dev/kvm --name netbsd \\\n    -e USER_ID=$(id -u) \\\n    -e USER_NAME=$(id -un) \\\n    -v ~:/bsd/home/$(id -un) \\\n    -p 2222:22 \\\n    madworx/netbsd\n\n$ ssh -p 2222 localhost \nNetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022\n\nWelcome to NetBSD!\n\n-bash-5.1$ id\nuid=1000(mad) gid=100(users) groups=100(users),0(wheel)\n-bash-5.1$ pwd\n/home/mad\n-bash-5.1$ cat foobar.txt\nHello, World.\n```\n\n#### `NETDEV`\n\nQEMU Device driver to use for network card. Defaults to `e1000`.\n\nTo use `virtio` (only works with HEAD NetBSD \u003e 2022-XX-XX), use `virtio-net-pci`.\n\n### Run a specific command in NetBSD\n\n```\n$ docker run --rm -it madworx/netbsd uname -a\nNetBSD netbsd 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64\n```\n\n### Running extra commands after NetBSD boot\n\nTo run additional commands (such as downloading further software, issue build pipelines etc), create a file on your docker engine host operating system and mount it as /etc/rc.extra.\n\nThe contents of that file will be executed as a shell-script after NetBSD has booted.\n\n```\n$ echo \"hostname count_zero\" \u003e ./rc.extra\n$ docker run -v $(pwd)/rc.extra:/etc/rc.extra --device=/dev/kvm --rm -it madworx/netbsd:head uname -a\nNetBSD count_zero 9.99.100 NetBSD 9.99.100 (GENERIC) #0: Wed Sep 21 01:33:53 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64\n```\n\nYou can of course do a mount over `/bsd/etc/rc.local`, but then the `USER_ID` and `USER_NAME` auto-creation of users will need to be handled by your own script:\n\n```\n$ docker run -v $(pwd)/rc.local:/bsd/etc/rc.local --device=/dev/kvm --rm -it madworx/netbsd:head uname -a\nNetBSD count_zero 9.99.100 NetBSD 9.99.100 (GENERIC) #0: Wed Sep 21 01:33:53 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64\n```\n\n### Start in background, connect as root via ssh from host OS.\n```\n$ ssh-keygen -t rsa\n$ docker run --rm -d --device=/dev/kvm -e \"SSH_PUBKEY=$(cat ~/.ssh/id_rsa.pub)\" -p 2222:22 --name netbsd madworx/netbsd:9\n$ ssh -p 2222 root@localhost\nNetBSD ?.? (UNKNOWN)\n\nWelcome to NetBSD!\n\nWe recommend that you create a non-root account and use su(1) for root access.\nnetbsd# \n```\n\n... using `ssh-agent`:\n\n``` shell\n$ docker run --rm -d --device=/dev/kvm -e \"SSH_PUBKEY=$(ssh-add -L)\" -p 2222:22 --name netbsd madworx/netbsd:9\n$ ssh -p 2222 root@localhost\nNetBSD ?.? (UNKNOWN)\n\nWelcome to NetBSD!\n\nWe recommend that you create a non-root account and use su(1) for root access.\nnetbsd# \n```\n\n***There are more options for customizing user accounts, mapping your host OS home directory into the NetBSD system etc:*** Check the `docker-entrypoint.sh` for details, or even better, document it and do a PR towards this project. :-)\n\n## Container exit status\n\nFor single command executions (e.g. `docker run madworx/netbsd ps`), the exit status of the container will be the exit code of the given command.\n\n### Special cases:\n- `242` -- While attempting to run a specific command (e.g. `docker run madworx/netbsd uname -a`), the qemu process disappeared.\n\n  This indicates an error with the QEMU configuration, such as an invalid value of the `NETDEV` environment variable.\n\n  The QEMU error message should be visible as docker container output.\n\n- `42` -- Internal \"default value\" which shouldn't really happen. Submit a PR if it does.\n\n## FAQ\n\n### Where is the console/boot output?\n\nDepending on how the container is invoked you will get different behaviors with regards to console input/output, described below:\n#### Attached mode\n\nIf you run the container in attached mode (`docker run -it madworx/netbsd`), you will get an \"interactive\" system where you can communicate with the NetBSD serial port. This enables you to read the kernel messages when booting, and logging in at the login prompt.\n\nN.B: Pressing `[Ctrl]-[C]` will of course kill the container, so it's not a mode meant to be used on a regular basis, however, for just \"kicking the tires\" on this image, or if you're doing NetBSD kernel development it can be quite useful.\n\n#### Invocation with a provided command to be run\n\nIf you run the container with a command to be executed (`docker run madworx/netbsd uname -a`), it doesn't matter if you request a tty or not, serial port output will be suppressed, and the only output from the container invocation will be the output of the command requested.\n\n#### Detached mode\n\nRunning the container in detached mode (`docker run --name netbsd -d madworx/netbsd`) will make all output from the kernel (serial port) go to the docker logs.\n\nThis mode is typically used if you're going to be using the continer for multiple tasks/daily usage etc. The docker container logs (`docker logs netbsd`) can help you diagnose issues that are printed by the kernel, but does not allow you to enter text into the serial port.\n\nAnother distinction is that this mode, when the container is stopped, will shut down NetBSD properly by pressing the \"virtual poweroff\" button. See `docker-entrypoint.sh` for details.\n\n### I'm trying to invoke (`docker run ... command`) a less-than-trivial chain of commands and it doesn't work.\n\nThis is most likely due to the fact that this container uses `ssh` internally for the communication between the NetBSD operating system and the Linux environment running inside the docker container, combined with how `ssh` handles commands \u0026 arguments, which is rather counter-intuitive.\n\nI believe the following example illustrates the point:\n\n```\n$ ssh localhost 'cd /tmp \u0026\u0026 pwd'\n/tmp\n\n$ ssh localhost sh -c 'cd /tmp \u0026\u0026 pwd'\n/home/mad\n```\n\nOne work-around is to mount volumes into docker, e.g:\n\n```\n$ cat \u003e code/run_my_commands.sh \u003c\u003cEOT\n#!/bin/ksh\n\nset -e\ncd /work\ncurl -O 'https://my.download.site/deployment.tar.gz'\ntar zxf deployment.tar.gz\n\n#\n# Any output that below script writes to stdout/stderr\n# will be visible in the docker container logs, as well\n# as the exit code of this script.\n#\n./my_pipeline_script.sh\nEOT\n$ chmod +x code/run_my_commands.sh\n$ docker run \\\n    --device=kvm --rm -it \\\n    -v $(pwd)/code:/bsd/work\n    madworx/netbsd:head \\\n        /work/run_my_commands.sh\n```\n\n### Why is it slow?\n\nIf you feel that the container is slow in starting/responding, or you are getting the message \"Warning: Lacking KVM support - slower(!) emulation will be used.\" upon startup, it means that you are either not exposing KVM to your container (`--device=/dev/kvm` when invoking `docker run`), or your operating system doesn't support KVM.\n\nNot having support for KVM might be due to that you are running your Docker engine inside a virtual machine and that your host doesn't have support for nested virtualization.\n\nFor instance, when running a QEMU virtual machine under physical hardware, it is entirely possible to run this image with KVM support. (Which is the setup for the main development environment for this image).\n\n### Why does building take a long time?\n\nDocker engine doesn't support building with `--device=/dev/kvm` or privileged mode. (See above)\n\n### I'd like to emulate other architectures than `amd64/x86_64`\n\nWhen running without KVM support, other target architectures supported by QEMU may be more efficient, but this is not something that has been tried out yet. (Feel free to try it out and submit a PR - n.b. the `madworx/qemu` image currently only targets x86_64 so you'll need to rebuild it as well)\n\n## Source\n\nSource code is hosted on [GitHub](https://github.com/madworx/docker-netbsd).\n\n## Contributions\n\nAny and all contributions are welcome in form of pull requests.\n\n## Author\n\nMartin Kjellstrand [provider+github@madworx.tech]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadworx%2Fdocker-netbsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadworx%2Fdocker-netbsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadworx%2Fdocker-netbsd/lists"}