Docker OpenWrt Image Generation
See also Docker OpenWrt Image
You can use a premade Docker image to build yourself an OpenWrt firmware image. A list of known such Docker images (see instructions how to use them on their pages):
- Official OpenWRT Docker images which can be pulled from Docker hub
- wlan slovenija image generator
- Roll your own using either Alpine or Debian containerfiles.
Building OpenWRT using Docker
First, an image needs to be obtained. Lets start with the most basic example, where a custom container is build. This can be skipped by instead pulling one of the OpenWRT containers from a container registry.
After placing (either) downloading either/both of these files, a OpenWRT repository is needed. After cloning or downloading the OpenWRT repository it might be a thought to create a dedicated worktree, when not wanting to build using master.
cd <openwrt repo>; git worktree add ../openwrt-<branch name> -b <branch name>; cd ../openwrt-<branch name>
. This will create a new git branch and check it out on a worktree.
Next, the container is to be built, using either podman or docker.
Note, while not strictly necessary, we don't want to copy all of the repository files into the container context. Doing so won't hurt or break anything, but it wastes space and costs time and won't even be accessible when running the container.
To avoid copying needless files, a .dockerignore file is used, which can be either in the same location as the Dockerfile or in the current working directory.
echo "*" > .dockerignore
Building the container is as simple as:
docker build --rm --tag openwrt:alpine --file <path-to-containerfile>/Containerfile-alpine <path-to-openwrt>
The tag can be named whatever of course, dated or likewise. The container only occasionally has to be rebuild, when 'host dependencies' are changed or updated.
Finally, the container can be used to launch a build environment
docker run --interactive --rm --tty --ulimit 'nofile=1024:262144' --volume "$(pwd):/workdir" --workdir '/workdir' openwrt:alpine /bin/bash <hostname>:/workdir$
From here, any normal OpenWRT command can be used as expected (`make menuconfig` etc). It is recommended to create an alias such as
alias make='make -j10 V=sc'
to build more verbose with multiple jobs, but this is completely optional.
OpenWrt Cloud Builder API
To facilitate easy sharing, reuse, and swapping of builders and testing out of new firmwares in the wider OpenWrt community, the following standard is proposed.
Project specific OpenWrt Buildroot
To facilitate sharing an project specific OpenWrt buildroot in such a way non Docker or Linux experts can understand. https://github.com/Doodle3D/openwrt-buildroot-example