Creating Layered VxWorks Containers and Deploy With Dockerhub
Table of Contents
- 1. Introduction
- 2. Prerequisites
- 3. Related Documentation
- 4. Prepare the Container-Enabled VxWorks Projects
- 5. Create the Philosophers Example RTP Project
- 6. Create the Bottom Container
- 7. Create the Top Container
- 8. Build the OCI Container Image Files
- 9. Push the philContainer OCI Image File to DockerHub
- 10. Pull topcontainer to the VxWorks Target Board
- 11. Go Further
1 Introduction
Containers allow the packaging of VxWorks applications that are isolated from the rest of the system. VxWorks containers can be deployed into the cloud repository called Dockerhub, and distributed to VxWorks target boards from there.
In this blog, I will show how to create two related containers. This shows how you can construct your application from multiple containers where one is treated as a library by the other.
In the workflow described in this blog, a top container is layered ontop of a bottom container. I will push the resulting layered container OCI image to DockerHub, and then deploy to VxWorks.
VxWorks is a Real Time Operating System built by Wind River.
VxWorks has board support package (BSP) for the Raspberry Pi 4 model B target board.
The Raspberry Pi 4 board is a small and affordable computer board.
DockerHub is a repository where Docker users store and distribute container images.
2 Prerequisites
These instructions assume that you are using:
1) A Raspberry Pi 4 model B board with 4GB RAM booting VxWorks
2) A USB-Serial TTL serial cable
3) A micro-SD card
4) A Windows workstation with the following installed on it:
Wind River VxWorks 7, SR21.07
The instructions assume you have a Docker Hub login. Refer to https://hub.docker.com/ for details.
They also assume you have configured your workstation with the buildah utility. This is used to build OCI compliant containers. For details, refer to the VxWorks Container Programmer’s Guide, Configure the Build Workstation for Containers.
Finally, you must have successfully completed the blog entitled Convert a VxWorks 7 RTP to Container and Deploy With Dockerhub. I will refer to this as the convertBlog.
3 Related Documentation
For more information on these topics, refer to:
Wind River documentation:
VxWorks Container Programmer’s Guide
4 Prepare the Container-Enabled VxWorks Projects
Create and build your VxWorks VSB and VIP to support containers. Follow the instructions in convertBlog.
5 Create the Philosophers Example RTP Project
Create and build your philosophers RTP project. Follow the instructions in convertBlog.
6 Create the Bottom Container
The bottom container will hold a data file and an RTP executable. It will not, however, be an executable container. I will
not define a container entrypoint for botomContainer.
6.1 Create a Directory for the Container
Return to your Windows command shell.
cd <YOUR_WORKSPACE> // your workspace
mkdir bottomContainer // a new directory for your bottom container
6.2 Copy the Philosophers RTP executable to the Bottom Container Directory
copy philosophers\rpiVSB_ARMARCH8Allvm_LP64_ld\philosophers\Debug\philosophers.vxe bottomContainer\.
6.3 Create a Bottom Comtainer Data File
cd bottomContainer
Create a text file called bottomContainer.txt. I will use this file for illustrative purposes only.
6.4 Create the Bottom Container Dockerfile in an Editor
This file must be a text file and it must be named Dockerfile without a .txt extension to the directory name.
FROM scratch WORKDIR /vxbottom COPY philosophers.vxe /vxbottom COPY bottomContainer.txt /vxbottom
Save the file in the bottomContainer directory.
Note:
If the editor appends .txt to the directory name on save, you must remove it. For example:
rename Dockerfile.txt Dockerfile
7 Create the Top Container
The top container will be layered ontop of the bottom container. It will be an executable container and will define an
entrypoint which is fulfilled by the bottom container.
7.1 Create a Directory for the Top Container
cd <YOUR_WORKSPACE> // your workspace
mkdir topContainer // a new directory for your top container
7.2 Create a Top Container Data File
cd topContainer
Create a text file called topContainer.txt. I will use this file for illustrative purposes only.
7.3 Create the Top Container Dockerfile in an Editor
This file must be a text file and it must be named Dockerfile without a .txt extension to the directory name.
FROM bottomContainer WORKDIR /vxtop COPY topContainer.txt /vxtop WORKDIR /vxtop ENTRYPOINT ["philosophers.vxe"] LABEL com.windriver.vxworks.rtp.rtpStackSize 0x400000 LABEL com.windriver.vxworks.rtp.rtpPriority 50 LABEL com.windriver.vxworks.rtp.rtpOptions 0x80 LABEL com.windriver.vxworks.rtp.rtpTaskOptions 0x00
Save the file in the topContainer directory.
Note:
If the editor appends .txt to the directory name on save, you must remove it. For example:
rename Dockerfile.txt Dockerfile
8 Build the OCI Container Image Files
cd .. cd bottomContainer wsl buildah bud --arch arm64 --os vxworks -f Dockerfile -t bottomcontainer cd .. cd topContainer wsl buildah bud --arch arm64 --os vxworks -f Dockerfile -t topcontainer
9 Push the philContainer OCI Image File to DockerHub
cd .. cd bottomContainer wsl buildah push bottomcontainer oci:bottomcontainer.oci wsl buildah push --creds dockerAccountName:dockerAccountPassword bottomcontainer docker://dockerAccountName/bottomcontainer.oci cd .. cd topContainer wsl buildah push topcontainer oci:topcontainer.oci wsl buildah push --creds dockerAccountName:dockerAccountPassword topcontainer docker://dockerAccountName/topcontainer.oci
Note:
dockerAccountName = the docker ID for your Docker Hub account
dockerAccountPassword = your Docker Hub account password
10 Pull topcontainer to the VxWorks Target Board
Because topcontainer is a layered container, the bottomcontainer blobs will automatically be pulled to the target when we pull topcontainer.
10.1 Set the VxWorks date correctly
-> cmd [vxWorks *]# date 2021-09-27 ok [vxWorks *]#
Note:
This instruction assumes the date of 27th September 2021. Set the date to the current date at time of using this blog.
10.2 Check your Internet connectivity
[vxWorks *]# C -> ping "www.google.com" Pinging lhr25s34-in-f4.1e100.net (142.250.187.228) with 64 bytes of data: Reply from 142.250.187.228 bytes=64 ttl=114 seq=0 time=16ms --- lhr25s34-in-f4.1e100.net ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 17 ms rtt min/avg/max = 16/16/16 ms value = 0 = 0x0 -> cmd [vxWorks *]#
Note:
You may need to wait a while until the END driver finishes configuring the ethernet PHY. Once the RJ45 connector LEDs have stopped flashing, configuration is done.
10.3 Pull topcontainer to the Target and Unpack the Bundle
Because bottomcontainer is layered beneath topcontainer, I only need to pull topcontainer to the target. The bottomcontainer blob files are automatially pulled as well
as the topcontainer blob files.
[vxWorks *]# vxc pull dockerAccountName/topcontainer.oci -k [vxWorks *]# vxc unpack --image topcontainer.oci --rootfs layered /ram0/topcontainer
Note:
dockerAccountName = the docker ID for your Docker Hub account
10.4 Create the Container from the Bundle
Once the container bundle is unpacked, create the container on the target and find both the vxbottom and vxtop directories in my container root file system.
[vxWorks *]# vxc create --bundle /ram0/topcontainer topc [vxWorks *]# cd /overlay/topc [vxWorks *]# ls . .. vxbottom vxtop [vxWorks *]# cd vxtop [vxWorks *]# ls . .. topContainer.txt [vxWorks *]# cd .. [vxWorks *]# cd vxbottom [vxWorks *]# ls . .. bottomContainer.txt philosophers.vxe
10.5 Start topcontainer Running
[vxWorks *]# vxc start topc Resume the RTP's initial task to end the demo. Running claim-based solution. Philosopher 1 is thinking... Philosopher 3 is thinking... Philosopher 4 is thinking... Philosopher 2 is thinking... Philosopher 5 is thinking...
10.6 Stop the Container Running
[vxWorks *]# vxc kill topc
11 Go Further
Create a third container which also uses bottomcontainer as a shared resource and observe how this makes efficient use of target resources because the files in bottomcontainer
are only copied to target memory once even though they are used by multiple top containers.