Example docker environment for building images for a specific project.
Make sure you have the following dependencies installed.
Checkout this repository and run Run.sh
.
$ git clone https://github.com/Doodle3D/openwrt-buildroot-example.git
$ cd openwrt-buildroot-example
$ ./Run.sh setup
Use ./Run.sh help
to view available commands.
This buildroot is a sharable build environment to build OpenWRT images with a custom project specific configuration and packages. The resulting image can be flashed to a OpenWRT compatible device, currently specifically the TP-Link MR3020. Instead of contaminating your machine with lots of build dependencies, which vary per operating system, we put the OpenWRT buildroot in a separated virtual machine using Docker (Understanding docker). This makes it easier for a team to work on an OpenWRT project. Because the Docker image (with most of OpenWRT precompiled) can be shared the build time will decrease dramatically. One of the goals is to make it simple enough for non Docker or Linux experts to grasp and use.
We created Run.sh to automate the most common use case; building an image and flashing this to a OpenWRT device.
Clone this repository
$ git clone https://github.com/Doodle3D/openwrt-buildroot-example.git
$ cd openwrt-buildroot-example
Build image from Dockerfile (normally this is downloaded from Docker Hub) This is done according to our Dockerfile.
$ docker build -t yourcompany/openwrt-buildroot dockerfile/
Run as interactive docker container.
This enables you to access the buildroot container and make changes.
Using our Run.sh:
$ ./Run.sh interactive
Original command:
$ docker run -t -i -v "$PWD/bin:/home/openwrt/shared/bin" -v "$PWD/customfeeds:/home/openwrt/shared/customfeeds" -u openwrt --name buildroot yourcompany/openwrt-buildroot bash
user@container: $ exit # exit container
$ docker ps # show running containers
$ docker ps -a -s # show all containers with size
$ docker start <NAME> # (re)start container
$ docker attach <NAME> # attach to container
# docker pull <IMAGE_NAME> # update an image
Since rebuilding the image takes a lot of time, it's usually more convenient to update the image. This can be done by creating a container from an image, updating the container and committing these changes into the image.
# Create & run an image interactively executing bash instead of Build.sh
$ docker run -t -i -u openwrt --name openwrt-buildroot yourcompany/openwrt-buildroot bash
# Make the changes and exit the container...
# Commit the changes back into the image, while restoring the command to Build.sh. You can specify what's changed with a message using the -m flag.
$ docker commit -c "CMD /home/openwrt/bin/Build.sh" -m="{change message}" openwrt-buildroot yourcompany/openwrt-buildroot
Kitematic is a gui to make using Docker easier. It creates a Docker host (Virtual machine) in which the Docker deamon, images and containers live. Our Run.sh script will automatically start the Docker Host. You can also start the Docker host manually using:
$ docker-machine start dev
For Docker to access this Docker Host it needs certain Environment variables. Our Run.sh script will export these automatically for that session. You can also include the following line in your ~/.bash_profile
to have these permanently available.
eval "$(docker-machine env dev)"
Save and $ source ~/.bash_profile
to load the changes.
When docker or docker-machine isn't found, please try: