For some obscure reason, Apple blocks me from accessing my own files with the Terminal. To allow Terminal to access all files and folders, I have to give Terminal the rights for “Full Disk Access” under “Security & Privacy
” in the “System Preferences
“.
Author Archives: Rolf
Delete locked files on macOS with the Terminal
Unlock the file:
chflags nouchg filename.txt
Options
-R
recursively change files-v
verbose
References
Transfer a Docker Image from Mac to Pi
TLDR
It didn’t work out. Don’t bother repeating it. It seems that with this way, the image is not of the correct architecture!
Aim
I’d like to transfer Docker images without depending on an external repository like Docker Hub.
Protocol
Check the images:
docker images
Save the image to a tar file:
docker save -o myImage.tar rolfsuter/testmultiarch:latest
Copy the tar file to the Pi:
scp myImage.tar pi@[IP]:myImage.tar
Connect to the Pi:
ssh pi@[IP]
List the current Docker images on the Pi:
sudo docker images
Load the image from the tar file:
sudo docker load -i myImage.tar
Check the image. Run:
sudo docker run --rm rolfsuter/testmultiarch:latest uname
Response:
standard_init_linux.go:211: exec user process caused "exec format error"
References
Exploring F# with .NET and Docker on Raspberry Pi
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.
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.
References
Working with Docker
Here are some notes about working with Docker. On my Raspberry Pi I need to run all commands as sudo
.
First of all, do not confuse the different terms. An image is like a blueprint that serves to generate containers. The containers are then the actual instance that you can start or stop.
List images
docker images
List containers
- Show the running containers:
docker ps
- Show all containers:
docker ps -a
- Use the
container
command. I don’t know it it differs from theps
command above. The output seems to be the same.
docker container ls
Start a container
- List the available containers (see above)
- Get the container ID to start
- Run
docker start [Container ID]
e.g.
docker start 725dc751823b
Exit a container without stopping it
If started a container with the docker run
options -i
and -t
, you can detach from it and leave it running:
- Press
[Ctrl]
+[p]
followed by[Ctrl]
+[q]
Connect/attach to a running container
docker attach [Container ID]
References
Run Pi-hole in a Docker container on a Raspberry Pi
I set up Pi-hole on a Raspberry Pi already a while ago and it is running fine. These are my notes that I took during installation. Unfortunately, the lack some details…
- Download the ‘
docker_run.sh
‘ script from https://github.com/pi-hole/docker-pi-hole/blob/master/docker_run.sh - Transfer the script to the Raspberry Pi
scp docker_run.sh pi@[IP]:docker_run.sh
- Connect with SSH to the Raspberry Pi
- run the script
sudo sh docker_run.sh
The script starts well but then encounters an issue after running the container:
Starting up pihole container docker_run.sh: 19: [: healthy: unexpected operator
.docker_run.sh: 19: [: healthy: unexpected operator
.docker_run.sh: 19: [: healthy: unexpected operator
.docker_run.sh: 19: [: healthy: unexpected operator
List all Docker containers
sudo docker container ls
Check the container
sudo docker inspect [Container ID]
Set the password for Pi-hole
Search the log file for the password
sudo docker logs pihole