I know technically host networking isn't supported MacOS (see https://docs.docker.com/network/host/)
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.
However it does actually seem to work. E.g. this works just fine:
docker run \
  --name local-mysql \
  -e MYSQL_ROOT_PASSWORD=foo \
  -e MYSQL_DATABASE=baz \
  --network="host" \
  -d mysql:latest
However when I try to conditionally specify the host networking with a bash variable, it doesn't work, and I can't make sense of it.  Consider the following test.sh:
#!/bin/bash
echo "Test 1"
docker rm -f local-mysql
docker run \
  --name local-mysql \
  -e MYSQL_ROOT_PASSWORD=foo \
  -e MYSQL_USER=master \
  -e MYSQL_PASSWORD=bar \
  -e MYSQL_DATABASE=baz \
  --network="host" \
  -d mysql:latest
docker ps
sleep 5
echo "Test 2"
export NETWORKING='--network="host"'
docker rm -f local-mysql
docker run \
  --name local-mysql \
  -e MYSQL_ROOT_PASSWORD=foo \
  -e MYSQL_USER=master \
  -e MYSQL_PASSWORD=bar \
  -e MYSQL_DATABASE=baz \
  ${NETWORKING} \
  -d mysql:latest
docker ps
This yields:
% ./test.sh
Test 1
local-mysql
6bbd68f0564943b8fb66ed37f1e639b54719bdb3b88b4e13aeef0a11cae4090b
CONTAINER ID   IMAGE          COMMAND                  CREATED                  STATUS                  PORTS     NAMES
6bbd68f05649   mysql:latest   "docker-entrypoint.s…"   Less than a second ago   Up Less than a second             local-mysql
Test 2
local-mysql
e286028ef9a1a27f4226beb60e766cc163c289239ba506f63a71a35adbc73ef3
docker: Error response from daemon: network "host" not found.
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
I.e. when I hard code --network=host into the docker command, the container starts fine.  But the exact same parameter in an environment variable fails to start with network "host" not found.
I'm honestly not sure if this is a failure of bash or docker, but I can't actually figure out what's going wrong.
-- EDIT --
Changing
export NETWORKING='--network="host"'
to
export NETWORKING='--network=host'
works.  And for my purposes right now that's enough.  But just to be thorough... Why?  The working example has quotes in the value (--network="host"), so why does the shell expansion break the non-working example?  What if I wanted something like --network="my host"?
