Thursday, 14 May 2026

Using hosts mDns/Avahi for Docker images

I’ve been trying to run Docker containers at home with one specific requirement: they need to resolve .local hostnames via mDNS so I can avoid the headache of managing static IPs.

The catch is that many of the containers I use aren't mine. They are standard images from the community, and I didn't want to maintain my own forks or modify their internal configurations just to get networking to work. I wanted a way to make mDNS "just work" from the host side.

Since I’m not a "networking guy," this proved more difficult than I expected. I spent a few evenings asking AI for advice and manually punching in commands based on its suggestions, but that didn't go anywhere.

Enter Gemini CLI and --yolo

After a bit of frustration, I decided to eliminate the middleman (me) and let the AI work directly on the system. I spun up a fresh, empty VM, installed the Gemini CLI, and spec'd exactly what I wanted.

I asked the AI what permissions it needed to achieve the goal autonomously in --yolo mode, which turned out to be passwordless sudo access. I granted the privileges and let it rip. After a bit of processing, it produced a working solution that I could then safely apply to my actual host.

TASK.md

Task: Configure Docker for mDNS/Avahi Resolution

Objective

Configure the Linux VM so that Docker containers can resolve .local mDNS addresses (specifically roope.local) without modifying existing container images.

Steps

  1. Logging: Maintain mdns_setup_log.txt with all actions, including failures.
  2. Host Setup:
    • Install/Ensure avahi-daemon and systemd-resolved are active.
    • Configure systemd-resolved to act as a bridge for mDNS to standard DNS.
  3. Docker Setup:
    • Identify Docker bridge IP (docker0).
    • Update /etc/docker/daemon.json to use the host’s bridge IP as the DNS server.
  4. Validation:
    • Verify roope.local resolution from an unmodified alpine container.
    • Verify connectivity via ping.
  5. Output: Write the successful configuration steps to SOLUTIONS.md.

Required Permissions

  • Sudo access (NOPASSWD) for system configuration.
  • Docker CLI access.
  • Workspace write access.

 SOLUTION.md

Solutions: Docker mDNS/Avahi Resolution

To enable Docker containers to resolve .local mDNS addresses without modifying images, the following steps were taken:

1. Configure systemd-resolved

A drop-in configuration was created to enable mDNS support and allow the stub listener to respond on the Docker bridge IP.

File: /etc/systemd/resolved.conf.d/mdns.conf

[Resolve]
MulticastDNS=yes
DNSStubListenerExtra=172.17.0.1

2. Enable mDNS on Network Interfaces

mDNS was enabled on the main network interface (ens18) to allow systemd-resolved to send/receive mDNS packets.

File: /etc/systemd/network/10-netplan-ens18.network.d/override.conf

[Network]
MulticastDNS=yes

3. Configure Docker

Docker was configured to use the host’s systemd-resolved stub listener (on the bridge IP) as the default DNS server for containers.

File: /etc/docker/daemon.json

{
  "dns": ["172.17.0.1"]
}

4. Services Restarted

The following services were restarted to apply changes:

sudo systemctl restart systemd-networkd
sudo systemctl restart systemd-resolved
sudo systemctl restart docker

5. Validation

Resolution was verified from an unmodified alpine container:

sudo docker run --rm alpine ping -c 1 roope.local

Output:

PING roope.local (192.168.0.106): 56 data bytes
64 bytes from 192.168.0.106: seq=0 ttl=63 time=0.714 ms

A Note on Security

I can't stress this enough: do not run AI in a production environment, especially with root privileges and --yolo mode enabled. Don't even do it on your primary development machine.

By using a throwaway VM, the risks were zero. If the AI decided to rm -rf / or wipe the partition, I'd just revert to a snapshot and try again. The absolute worst it could do was try to flood my LAN, which is a much smaller headache than a deleted home directory.


Thursday, 11 June 2020

Wooden handle for Rok espresso machine

The handle for our Rok espresso machine started to crack, decided it was too much work to find out how to order a new one, better make one myself. There was some apple tree that seemed like good choice.


Finished the handle with some oilwax, only one coat. Might put a few coats more in the future, we'll see how it holds.



Wednesday, 11 December 2019

Kona Ute head tube attached front rack

I bought a Kona Ute this fall, I like it, but we have two kids and they take all the space in the back so I needed some kind of front rack. I had previously had a front rack that attached to the front fork but found it cumbersome as it added to the mass that had to be turned when steering. So I wanted a rack that would attached to the frame. After some digging I couldn't find one, so I decided I would make one myself.

Kona Ute doesn't really have any good place for attaching a front rack to the frame, so I decided to bolt it to the head tube with two u-bolts. Luckily I had the old fork mounted rack still, so I only needed to build something to hold it in place. And the old rack was aluminium so it weights less.

Didn't take any pictures while building it, but it was just basically cutting some pieces and then welding them together.




Finished rack, color was chosen by my daughter:)


Saturday, 10 March 2018

Solar heat, update.

Some points I noticed while my solar heat system was installed last spring.

The glass cracked in couple of days, most likely the window frame was too tight. It was probably loose enough for normal use but in my use it heated to over 50 degrees and I'm guessing that was too much. Next time I'll make a new frame and make sure the glass is really loose in there.

I'm measuring the small solar panel wrong, I should be measuring amps and not voltage. Needs to be fixed sometime in the future.

ESP8266 real time clock is very inaccurate. I fixed this by ignoring the time sent and using the receiving servers time.

There's not enough error handling in my code and sometimes it crashes, most likely it's in the MQTT or NTP part, network trouble probably.

Using just convection didn't give that much heat so I added a fan. Currently it starts the fan when heated temperature is 20 degrees above inside temperature, when heated temperature is less than 10 degrees above room temperature then fan speed is decreased.

I used a standard 120 mm computer case fan I had lying around. "Case" for the fan was fabricobbeled from plastic cellular board I had salvaged from trash.


Here's an example of a sunny day, blue is outside temp (north side of the house), red is bottom of the collector, yellow is heated air and green is inside of our garage. Magenta is the "speed" of the fan, it's actually 10 bit pwm value of the ESP8266, as the fan doesn't have a pin for measuring speed, but it gives some idea on how fast the fan is running.

Updated source and Fritzing scheman can be found on github. https://github.com/mika-koivusaari/solar_air_heat_controller

Friday, 5 May 2017

Weather page

I've had a weather station at our summer house for some time now, but I never got around to publishing the the data. Now I had some time and made a Spring Boot application to show the data.

Station consists of 1-Wire sensors from Hobby-Boards. Temperature, barometer, wind speed and direction and rain sensors. I'll probably add a relative humidity sensor sometime so I can calculate the heat index also, currently only wind chill is calculated.

Since the weather station is located at our summer house with a somewhat flaky internet connection I can't just directly save data to my home servers database. I first save it locally and then replicate it home by reading MySQL's binary log. https://github.com/mika-koivusaari/replicate_mysql_postgresql Machines are connected with an SSH tunnel, I use autossh to make sure the tunnel is always open.

Weather page is https://weather.khyron.dy.fi/weather (in finnish), and code in https://github.com/mika-koivusaari/weather.

Friday, 17 March 2017

Solar heat

Our garage currently has no heating, sometimes when it's cold for a long time I put a electric heater there to make sure it doesn't go below freezing. For some time now I have thought about making a solar heater there and now I had some time to do it. One of the outside walls faces south and there is already an air intake, so that's a good starting point. I decided to only heat the incoming air and not make a full blown solar heat system with water circulation, it's cheaper and also I like to start small.

Collector

A house near us had it's windows replaced so I got one of the old ones for free. It was about the right size which reduced the work needed. Basically it's just a wooden box with polyurethane insulation I found in a dumpster, with the window put in front. Just behind the window is a tin foil paper with the paper side painted black and facing the window and sun. That way space where air heats and comes inside is covered with aluminium and there is no paint that might give out some fumes when heated. I ran out of paint so the collector isn't painted as black as it should, I'll probably paint it better in the summer as I have to take it out anyway so our garage wont heat too much. But I thought it would be good to get it installed and making heat, I can make it better later when I have some more data on how it works.

Controller

The controller needs foremost to control the flap on the air intake, because there are usually no people in the garage there is no need to get fresh air all the time, so the flap can be closed when there is no heat coming. Generally when air is hotter inside the collector we open the flap more, and when it's colder we close the flap some more. For operation there's only need for two temperature sensors, heated air and inside air, but I also want to monitor cold air coming to the collector so I have three sensors. That way I can monitor how much air heats and whats the temperature difference between north and south sides of our house. There is no fan, air is only moved by convection.

I also had a small solar cell from a Ikea garden lamp, which I added to get some reference to compare to when I make changes to the collector or controller. I put some resistors and diodes as a load, and scaled the voltage to 0 - 1 volts with a voltage divider.

All the values, temperatures, solar cell voltage and servo position are sent out with MQTT and then logged to a database so I can monitor how it works. And when I make changes I can see if it was a good or bad change.

On the left the protoboard version, and on the right the final veroboard version. Power supply is just some generic psu I had lying around as I use two dc-dc converters to make the needed 5 (LCD and servo) and 3.3 (ESP8266 and DS18B20 sensors) volts.


Controller in it's "final" installation. After one day I lowered the position of the servo some. It only opened the flap a few centimeters, now it opens some more.



Source and fritzing files can be found in github https://github.com/mika-koivusaari/solar_air_heat_controller

Thursday, 26 January 2017

MQTT MySQL gateway

Previously I've made a couple of sensors that send data with MQTT. Of course that data should be stored in a database. Considering that I'm probably going to make more wireless sensors that send data for example from our heating system it's best to write a easily configurable MQTT to database gateway. This gateway should also be able to send new values from database to MQTT nodes for displaying, as some data is gathered in other ways and inserted directly to db, for example OWFS(1-wire) or homegrown pulse counters.

So the basic functionality would be:
  • Recieve data from MQTT, process and save it to MySQL
  • Follow MySQL binlog and send saved data to MQTT
For input I need to have a table that stores:
  • Subscribed topic.
  • How to get raw sensorid from topic, maybe regexp.
  • How to parse data from message.
  • Small script that processes the data so it's ready to store.
And a second table that's used to convert raw sensorid's to db sensorid's:
  • Rawid
  • Sensorid
For output I need a table that stores:
  • Sensorid
  • Topic to push data to
  • How to process data before sending
There are still some features to implement, like outputting data from db to MQTT, need to think how this should be done with some kind of plugin system, MySql will probably use binlog to read data, but other databases have other mechanisms.

There are depencies for Paho-MQTT clientpep3143daemon and SQLAlchemy. More detailed dependencies in requirements.txt

Code in GitHub https://github.com/mika-koivusaari/mqtt_db_gateway.