Skip to main content
Summarise the purpose, not the concerns, in the title
Link
Toby Speight
  • 88.3k
  • 14
  • 104
  • 327

Is this docker Docker entrypoint bash script for passing parameters to the containerized app 'good'?

Source Link

Is this docker entrypoint bash script for passing parameters to the containerized app 'good'?

Source code located here

I am trying to pass extra parameters from a container to the contained application. The following bash script is working to pass extra variables, but I'm not sure that it's optimal, or a standard method for running a containerized application. Any insight would be appreciated.

#!/bin/bash

# allow arguments to be passed to dnsmasq
if [[ ${1:0:1} = '-' ]]; then
  EXTRA_ARGS="$@"
  set --
elif [[ ${1} == dnsmasq || ${1} == $(which dnsmasq) ]]; then
  EXTRA_ARGS="${@:2}"
  set --
fi

# default behaviour is to launch dnsmasq
if [[ -z ${1} ]]; then
  echo "Starting dnsmasq..."
  exec $(which dnsmasq) --log-facility=- --keep-in-foreground --no-resolv --no-hosts --strict-order ${EXTRA_ARGS}
else
  exec "$@"
fi