Recently, I got a Raspberry Pi 3 Model B. Now, I’d like to figure out, if I can run an F# server in a Docker container on it. I am aware that the currently installed Raspberry Pi OS is actually a 32-bit OS while the processor of my Pi has an 64-bit architecture. This has an impact if I’d like to install .NET directly on the OS. Since I intend to use Docker, I’ll sort that out later and just try to get it going.
Proof of principle
Try to run a container with .NET installed:
sudo docker run -it microsoft/dotnet:latest |
Since I managed to spin up a .NET container, the next step is to create an F# console application and run it:
mkdir test cd test |
dotnet new console -lang "F#" |
dotnet run |
I am also able to run the dll file directy:
dotnet bin/Debug/netcoreapp2.1/test.dll |
To exit the container and keep it running, I press [ctrl]
+ [p]
followed by [ctrl]
+ [q]
.
Bind mount a host directory
First I create in the current directory a folder hostFolder
containing a subfolder on the host system. I’ll mount hostFolder
into the container below.
mkdir hostFolder mkdir hostFolder/subfolder |
Then I create a container from the image microsoft/dotnet:latest
. Using the -v
flag, I mount the hostFolder
into the /targetFolder
in the container. Note that the directory targetFolder
is created in the root directory (/
). The term "${PWD}"/hostFolder
determines the path of the hostFolder to mount with ${PWD}
being the current working directory. The part after the colon :
with the path /targetFolder
defines the mount point in the container. The -w
flag determines the working directory in the container. Thus, I get directly into the /targetFolder/subFolder
directory in the container.
sudo docker run -it \ -v "${PWD}"/hostFolder:/targetFolder \ -w /targetFolder/subfolder \ microsoft/dotnet:latest |
For testing I create a test file within the subfolder
on the container and see it on the host system.
1 | sudo docker run -it -v "${PWD}"/Source/Repos/Lab/TestApp:/TestApp -w /TestApp microsoft/dotnet:latest |
Add a Dockerfile
A Dockerfile describes how Docker creates an image and runs it. However, I’d like to develop on my Mac and try to setup the docker image there. Thus, I’ll setup a SAFE stack app on my Mac in another post.