I’m having trouble connecting to the correct abstract unix socket inside a docker container after the host is restarted.
At container creation, I set the container’s DBUS_SESSION_BUS_ADDRESS to the current value of the host’s DBUS_SESSION_BUS_ADDRESS. Everything works as expected. After the host is restarted, its DBUS_SESSION_BUS_ADDRESS changed but the container still tried to connects to the old socket. To be more specific:
- host’s current
DBUS_SESSION_BUS_ADDRESSis/tmp/dbus-ABC - start container X and set its
DBUS_SESSION_BUS_ADDRESSto/tmp/dbus-ABC(same as host) - restart host
- host’s new
DBUS_SESSION_BUS_ADDRESSis/tmp/dbus-XYZ - restart container X
- get
"Failed to connect to socket /tmp/dbus-ABC: Connection refused"inside container because the host’s newDBUS_SESSION_BUS_ADDRESSis/tmp/dbus-XYZ
I know can fix this by update the value of container’s DBUS_SESSION_BUS_ADDRESS every time after I restart the host. But is there a way to automate this?