title: Challenged accessing containerized DNS-SD
body: <p>I'm a ZeroConf (and Rust) noob and I'm struggling to understand why I'm unable to access a service based upon the <a href="https://crates.io/crates/astro-dnssd" rel="nofollow noreferrer"><code>astro-dnssd</code></a> example when the code is containerized <strong>and</strong> run in a subshell.</p>
  <p>The following work:</p>
  <ol>
  <li>Running the binary and <code>avahi-browse</code> on the host:</li>
  </ol>
  <pre class="lang-sh prettyprint-override"><code>./server
  </code></pre>
  <p>Yields:</p>
  <pre class="lang-sh prettyprint-override"><code>avahi-browse -all
  + enp5s0 IPv6 asto-dnssd                                    _rust._tcp           local
  </code></pre>
  <ol start="2">
  <li>Running the binary in the container manually and <code>avahi-browse</code> on the host:</li>
  </ol>
  <pre class="lang-sh prettyprint-override"><code>docker run .... --entrypoint=bash [[image]]
  &gt; service dbus start
  &gt; service avahi-daemon start
  &gt; ./service
  </code></pre>
  <p>And:</p>
  <pre class="lang-sh prettyprint-override"><code>+ docker0 IPv4 asto-dnssd                                    _rust._tcp           local
  </code></pre>
  <ol start="3">
  <li>Running the binary in a subshell after starting <code>dbus</code> and <code>avahi-daemon</code>:</li>
  </ol>
  <pre class="lang-sh prettyprint-override"><code>docker run .... --entrypoint=bash [[image]]
  &gt; service dbus start
  &gt; service avahi-daemon start
  &gt; bash -c &quot;./service&quot;
  </code></pre>
  <p>But, if I start the services in the subshell <strong>and</strong> run the binary, nothing:</p>
  <pre class="lang-sh prettyprint-override"><code>docker run .... --entrypoint=bash [[image]]
  &gt; bash -c &quot;service dbus start &amp;&amp; service avahi-daemon start &amp;&amp; ./service&quot;
  </code></pre>
  <p>Why would this be?</p>
  <p>I have another example using the <a href="https://crates.io/crates/zeroconf" rel="nofollow noreferrer"><code>zeronconf</code></a> crate and this works fine this way.</p>
  <p>IIUC I must start <code>dbus</code> and <code>avahi-daemon</code> in the container image <strong>before</strong> the server and using a subshell is the correct (!?) approach:</p>
  <pre><code>ARG PROJECT=astro-dnssd
  
  FROM rustlang/rust:nightly-slim as builder
  
  ARG PROJECT
  
  RUN apt update &amp;&amp; \
      apt install -y libavahi-compat-libdnssd-dev
  
  RUN USER=root cargo new --bin ${PROJECT}
  
  WORKDIR /${PROJECT}
  
  COPY ./Cargo.toml ./Cargo.toml
  RUN cargo build --release
  RUN rm src/*.rs
  
  ADD . ./
  
  # Replace hyphens with underscores in ${PROJECT}
  RUN rm ./target/release/deps/$(echo ${PROJECT} | tr '-' '_')*
  
  RUN cargo build --release
  
  
  FROM debian:buster-slim as runtime
  
  ARG PROJECT
  
  WORKDIR /bin
  
  # Copy from builder and rename to 'server'
  COPY --from=builder /${PROJECT}/target/release/${PROJECT} ./server
  
  RUN apt update \
      &amp;&amp; apt install -y \
      libavahi-compat-libdnssd-dev \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  RUN mkdir -p /var/run/dbus
  
  ENTRYPOINT [&quot;bash&quot;, &quot;-c&quot;, &quot;service dbus start &amp;&amp; service avahi-daemon start &amp;&amp; ./server&quot;]
  </code></pre>