Hi everyone.
Necroposting here to let people know that I found a way to disable the console over the serial port directly from a docker container.
Long story short:
- Either add a new service or merge this with an existing one in
docker-compose.yml
:
environment:
- 'DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket'
labels:
io.balena.features.dbus: '1'
- Add
dbus
to your Dockerfile:
RUN install_packages dbus
- Run the following commands at runtime inside the container:
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
--system \
--print-reply \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.MaskUnitFiles \
array:string:"serial-getty@serial0.service" \
boolean:true \
boolean:true
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
--system \
--print-reply \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.StopUnit \
string:"serial-getty@serial0.service" \
string:replace
You can find a fully working example in this repository, as well as documentation and more in depth explanations: