Intro
Interestingly the VF2L image comes with docker included.
I decided it would be useful to see how this compares with my other docker setup PI43+OMV
I decided it would be useful to see how this compares with my other docker setup PI43+OMV
Images Available
There is an Docker Official Index of 48 riscv64 images as of January 26. There are various programming languages (Go, Ruby, Perl, python etc), a few OS guests (Debian, Ubuntu, Alpine), some webservers (Apache httpd, tomcat, nginx) and some others mainly technical utilities and a few applications (e.g. nextcloud).
Other examples have been created, usually, they are geared towards multiple architectures and include riscv64. For example I wanted a container I can SSH into so I googled "docker riscv64 ssh" and found woahbase/alpine-ssh.
This is based on the alpine docker image. I ran the image to build a container and I was able to ssh in to use it. This is excellent.
An alpine image is only 7MB size and including SSH only increase it to 14MB.
Docker doesn't create a complete VM, it uses the linux host kernel and syscall interface to provide an environment.
Alpine linux comprises a minimal set of utilities to make it useful, so it combines well with docker and is widely used.
Add applications to an image
Previously on my PI43:OMV server I have used docker compose to create images. I have pasted in configurations and used compose to build an image and run the container. I dont have docker compose or "standard" images on VF2L so I need to think and learn a little bit more about docker.
For my images / containers I start off from a minimal Alpine Image. I run this image as a container and I can access the container through a shell, enabling me to install software, create files, bring up Services etc.
My first experiment was to create an Alpine lighttpd container. I started by running a "raw" alpine:3.23 image.
I needed to add the openrc package plus a couple of extra commands allowing me to start services (this is a wrinkle in alpine setup).
I could then add the lighttpd package and start the web server on port 80.
In a web browser I can see the lighttpd installation placeholder page.
Create a lighttpd image
Now I know how to configure a container running a lighttpd webserver I need to create a new image including lighttpd which I can start up as a web server.
To do this I create a "Dockerfile" which contains commands to execute whilst building the image. These can include software installation using the Alpine "apk add" command and bringing up Services. A working image includes all necessary software (executables, configuration files, working storage etc). Based on the interactive setup I used the Dockerfile as shown here to build a "alpine-lighttpd" image for my webserver.
There is a small downside which needs to be dealt with; the raw image has no persistent storage. The container uses temporary files for all the storage it needs and this is deleted when the container is removed. So if I added some html files to the container they would be lost when I removed the container.
The answer is to create one or more volumes to contain our data. For my lighttpd web server the home page will be stored at /var/www/localhost/htdocs/index.html. with the command "docker create volume VarWwwLocalhost" I created a volume. I then mapped the volume to the home page directory in my docker run command which starts the container.
Now I could add index.html and other web pages within the container and they remain available each time the container is loaded.
In fact I can also access the volume from VF2L outside the docker container so I can look at or edit files from VF2L before starting the container. My first effort is shown below.
A vital feature of docker is that it allows you to redirect ports. When I run the lighttpd container I specify that I want to map VF2L port 8080 to my container port 80. Then any URL which specifies port 8080 is directed to the container port 80.
Outro
It is very useful to be able to create my own images or amend standard images for my requirements. Docker is an excellent tool for making these images and running the associated containers. VF2L has proved itself capable of running docker and docker containers. It is wonderful to separate the host OS linux from the image so that I am in total control of the container. VF2L runs StarFive linux but my images are built on alpine, but they could be built on Debian or Ubuntu.
So far I have built containers for lighttpd (described above) and for ssh access so that I can ssh into a test alpine server. I have also quickly started up nginx and nextcloud containers to experiment with them. I am quite amazed at how quick and easy it can be to start a complete application. If there is an appropriate image it is much simpler than adding linux packages to the operating system and configuring them.
No comments:
Post a Comment