Author Archives: Rolf

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 the ps 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…

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

References

Git: Remove ignored files

You can ignore files in git from being added to the repository by putting a .gitignore file into place. It might however happen that the .gitignore file seems not work. This is the case if you have already included the files in the git repository index.

To resolve the issue, you can perform these commands in your project directory containing the .git folder:

$ git rm -r --cached .
$ git add .
$ git commit -am "Remove ignored files"
  1. First, remove all the files from the git index. Don’t worry, this does not remove the actual local files.
  2. Then add back all files. The .gitignore file controls that git does not add the files to ignore.
  3. Finally, commit the changes.

References