cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2471
Views
6
Helpful
1
Comments
thulsdau
Cisco Employee
Cisco Employee

This how-to is a step-by-step guide to create a simple docker container which can run on IOx on IE3400.

Introduction

Unlike Catalyst 9300, which has a x86 (more specifically: x86-64) compatible CPU, IE3400 runs IOx apps on an ARM Cortex-A53 CPU. Therefor, any docker containers which are supposed to run on IE3400 need to have all binaries compiled for the aarch64 architecture.

One easy way to create such docker containers on a x86 Workstation/Server is to use qemu for CPU emulation.

Prerequisites

 

Step-by-step instructions

 

1. Install qemu-static

First, we need to install the qemu-user-static package and execute the registering scripts:

thulsdau@ubuntu1:~sudo apt install qemu binfmt-support qemu-user-static
thulsdau@ubuntu1:~$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Check to see if the aarch64 architecture was correctly registered with binftm: 

thulsdau@ubuntu1:~update-binfmts --display | grep aarch64
qemu-aarch64 (enabled):
 interpreter = /usr/bin/qemu-aarch64-static

Check if we can run native aarch64 docker images:

thulsdau@ubuntu1:~docker run --rm aarch64/alpine uname -m
Unable to find image 'aarch64/alpine:latest' locally
latest: Pulling from aarch64/alpine
e92c575fea6b: Pull complete
Digest: sha256:fea6984b3a5b422c41f20a95ff290e77405dd3cb4ff163dd3ad64572e41de0cf
Status: Downloaded newer image for aarch64/alpine:latest
aarch64
$

 

2. Create Dockerfile

Setup a new empty directory and create a file called "Dockerfile" with contents as shown below:

thulsdau@ubuntu1:~$ mkdir iperf3_dockerimage
thulsdau@ubuntu1:~$ cd iperf3_dockerimage/
thulsdau@ubuntu1:~/iperf3_dockerimage$ cat <<EOF >Dockerfile
> FROM aarch64/alpine:latest
> RUN apk add --update --no-cache ca-certificates iperf3 tcpdump
> EXPOSE 5201/tcp
> USER root
> CMD iperf3 -s
> EOF
thulsdau@ubuntu1:~/iperf3_dockerimage$ cat Dockerfile
FROM aarch64/alpine:latest
RUN apk add --update --no-cache ca-certificates iperf3 tcpdump
EXPOSE 5201/tcp
USER root
CMD iperf3 -s
thulsdau@ubuntu1:~/iperf3_dockerimage$

In this example we are basing the container on Alpine Linux, because of its small size. We are installing iperf3 and tcpdump as additional applications. And because a container needs a long-running process to stay alive, we have it execute the command "iperf3 -s" by default.

3. Build and export the docker image

 Build the docker image from the Dockerfile:

thulsdau@ubuntu1:~/iperf3_dockerimage$ docker build --tag iperf3_dockerimage_aarch64 .
Sending build context to Docker daemon 3.072kB
Step 1/5 : FROM aarch64/alpine:latest
---> 8e8812ba3b2d
Step 2/5 : RUN apk add --update --no-cache ca-certificates iperf3 tcpdump
---> Running in f1ef049be3c9
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/aarch64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/aarch64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/aarch64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/aarch64/APKINDEX.tar.gz
(1/4) Installing ca-certificates (20161130-r1)
(2/4) Installing iperf3 (3.1.3-r0)
(3/4) Installing libpcap (1.7.4-r1)
(4/4) Installing tcpdump (4.9.2-r0)
Executing busybox-1.25.1-r0.trigger
Executing ca-certificates-20161130-r1.trigger
OK: 6 MiB in 15 packages
Removing intermediate container f1ef049be3c9
---> 790cc0a830d6
Step 3/5 : EXPOSE 5201/tcp
---> Running in 0a493bb10de3
Removing intermediate container 0a493bb10de3
---> 00a32c498290
Step 4/5 : USER root
---> Running in b74366c14931
Removing intermediate container b74366c14931
---> e0f0ddb8aa33
Step 5/5 : CMD iperf3 -s
---> Running in 0313d88886ff
Removing intermediate container 0313d88886ff
---> 433b0e9be887
Successfully built 433b0e9be887
Successfully tagged iperf3_dockerimage_aarch64:latest
thulsdau@ubuntu1:~/iperf3_dockerimage$

Export the docker container:

thulsdau@ubuntu1:~/iperf3_dockerimage$ cd ..
thulsdau@ubuntu1:~$ docker save iperf3_dockerimage_aarch64 | gzip >iperf3_dockerimage_aarch64.tar.gz
thulsdau@ubuntu1:~$ ls -lah iperf3_dockerimage_aarch64.tar.gz
-rw-r--r-- 1 thulsdau thulsdau 3.7M Jun 4 06:56 iperf3_dockerimage_aarch64.tar.gz
thulsdau@ubuntu1:~$

Congratulations, you have successfully built a docker container which runs on ARM.

Comments
Martin L
VIP
VIP

interesting; thanks for sharing!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links