Docker Containers on RISC-V Architecture
Containers are part of the vast majority of daily interactions with software and the cloud these days. From building applications in a reproducible way to defining standards in deployment, containers brought ease and agility to IT.
RISC-V is a free and open-source instruction set enabling a new era of processor innovation through open standard collaboration. Born at the University of Berkeley, RISC-V ISA delivers a new level of free, extensible software and hardware freedom on architecture, paving the way for the next 50 years of computing design and innovation.
Together they bring real openness to the future of cloud ecosystem by having a top-to-bottom open solution ranging from the hardware to the end-user software.
In this article, first I will show how to have a Risc-V virtual machine, install Golang and Docker into it, then run and build containers in this environment.
Risc-V Virtual Machine
To start with development, I provide a Risc-V Virtual Machine based on Debian Sid with a complete enviroment where you can start developing and building your applications on the Risc-V architecture.
The VM tarball can be downloaded here. Unpack with
tar vxf debian-riscv64–20181123.tar.bz2 and run with the
Log-in on another terminal window with:
ssh -p 22222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost, the root password is “riscv”.
Soon I will also provide a Fedora development VM, the link will be added here.
Go support on Risc-V architecture is not upstream yet. You can check the progress on this issue. Many of it’s modules have already been upstreamed like
x/net. Also many libraries and applications already support the Risc-V architecture like VNDR, GitHub’s Hub (git client), Labstack Echo framework and more. Check the tracker on https://github.com/carlosedp/riscv-bringup.
To install Go, download the tarball from here and install with the commands:
# Download the tarball into the VM
wget https://github.com/carlosedp/riscv-bringup/releases/download/v1.0/go-1.13-riscv64.tar.gz# In the VM, unpack (in root dir for example)
tar vxf go-1.13-riscv64.tar.gz -C /usr/local# Add to your PATH
export PATH="/usr/local/go/bin:$PATH"# Add to bashrc
echo "export PATH=/usr/local/go/bin:$PATH" >> ~/.bashrc
And you are ready to develop in Golang on Risc-V!
After starting your VM, download and install the Docker deb with:
wget https://github.com/carlosedp/riscv-bringup/releases/download/v1.0/docker-19.03.5-dev_riscv64.debsudo apt install ./docker-19.03.5-dev_riscv64.deb
Reboot after install.
Now you can do
docker info and
docker version to check if it’s working (in case docker fails to start, just run
sudo systemctl start dockeragain.
As a test, I already pushed a container to DockerHub with a hello-world web application using Echo Framework.
The source for this small application and it’s Dockerfile is in the Risc-V Tracker repository.
Run this container with
docker run -d -p 8080:8080 carlosedp/echo_on_riscv and test it with
To build a container, just follow the default path of building your app, creating your Dockerfile and running
docker buildlike the example from the repo. Checkout that tree and use the Makefile for convenience:
Currently, there are no official base images supporting Risc-V but I’ve provided some on my DockerHub account:
- Debian Sid (Multiarch) ->
- Debian Sid Slim (Multiarch) ->
- Busybox (1.31.0) ->
- Go 1.13 (Multiarch) ->
For more details on building packages from source, check the tracker repo on https://github.com/carlosedp/riscv-bringup where I have instructions for Docker, Podman, Golang and more.
Container use on Risc-V architecture is pretty functional. Now the heavy work is to upstream Go, implement CGO support and have base images to build software.
If you have suggestions, want to join and start providing support to some projects, message me on Twitter or open an issue on the tracker repository.