For the shell to evaluate shell code stored in a variable, you'd use the eval special builtin command. That's the same as in several other languages:
cmd="--name=cloudflare-ddns \
--hostname=oznu-cloudflare-ddns \
--env=SUBDOMAIN=private \
--env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
--env=QEMU_ARCH=x86_64 \
--env=S6_KEEP_ENV=1 \
--env=S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
--env=CF_API=https://api.cloudflare.com/client/v4 \
--env=RRTYPE=A
--env='CRON=*/5 * * * *' --env=PROXIED=false \
--env=ZONE=thebiermans.net \
--env=API_KEY=kka \
--network=host \
--restart=always \
--log-driver=db --runtime=runc --detach=true -t oznu/cloudflare-ddns:latest"
eval "docker run $cmd"
That assumes the concatenation of "docker run " and the contents of $CMD forms valid code in the syntax of the shell. In that case, the interpretation of that code will result in the execution of the docker command with a list of arguments.
To run a command with a list of arguments stored in a variable, you'd use an array variable:
args=(
--name=cloudflare-ddns
--hostname=oznu-cloudflare-ddns
--env=SUBDOMAIN=private
--env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
--env=QEMU_ARCH=x86_64
--env=S6_KEEP_ENV=1
--env=S6_BEHAVIOUR_IF_STAGE2_FAILS=2
--env=CF_API=https://api.cloudflare.com/client/v4
--env=RRTYPE=A
--env='CRON=*/5 * * * *'
--env=PROXIED=false
--env=ZONE=thebiermans.net
--env=API_KEY=kka
--network=host
--restart=always
--log-driver=db --runtime=runc --detach=true
-t oznu/cloudflare-ddns:latest
)
docker run "${args[@]}"
In any case, in bash, do not leave parameter expansions unquoted in list contexts as that hardly ever does what you want. Doing that is the split+glob operator, which splits the contents of the variable on characters of $IFS and then performs filename generation on each resulting words. That is totally unrelated to shell syntax tokenisation and syntax parsing which are the parts that recognise and interpret quotes for instance.