As there are many reasons to use OpenWrt, I need to build OpenWrt image for my router at home as a part of my HomeLab project.

I prefer Archlinux as a base container image for OpenWrt build:

Arch Linux is an independently developed, x86-64 general-purpose GNU/Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is a minimal base system, configured by the user to only add what is purposely required.

This Archlinux container feature:

  • Share SSH key with the host
  • Share same UID, GID with the host for file editing
  • Build environment: Archlinux latest


Clone this repo:

git clone 
cd openwrt-docker-machine

Change UID, GID in Dockerfile to match your user information. You can find UID, GID from your current Linux box with idwhich are 1000, 1000, respectively in my ClearLinux box. By doing this, there is no read/write permission when compiling.

$ id 
uid=1000(bacnh) gid=1000(bacnh) groups=1000(bacnh),10(wheel),202(docker) script and docker-compose.yml is provided so you can login into the container bash script to interfact with OpenWrt build process:


# Start Docker
docker-compose up -d
docker exec -it openwrt-dev-machine /bin/bash

Start the bash inside the container to build OpenWrt image:

Creating openwrt-dev-machine ... done
[bacnh@59b1c14c9dfb opt]$

Then, follow the OpenWrt guidance to get source and compile your image.

$ git clone

Together with VSCode + Remote-SSH plugin, I am able to build OpenWrt image in my server remotely.

OpenWrt development using VSCode and Remote-SSHBuild uild BuiToge

Docker-compose usage

docker-compose.yml is provided inside the repo. You can customize to fit your need of bind mount.

version: '2'
    image: bacnh85/openwrt_dev_machine
    container_name: openwrt-dev-machine
      - "./:/opt/"
      - ~/.ssh:/home/tux/.ssh
    tty: true
    network_mode: bridge


Welcome anyone to raise PR to my github repo: