docker command line list arguments

When I am starting the docker daemon I am modifying the dns server so that the containers have a modified /etc/resolv.conf. Looking at the usage message I see:

$ docker --help
Usage: docker [OPTIONS] COMMAND [arg...]

A self-sufficient runtime for linux containers.

  --api-enable-cors=false                    Enable CORS headers in the remote API
  -b, --bridge=""                            Attach containers to a prexisting network bridge
                                             use 'none' to disable container networking
  --bip=""                                   Use this CIDR notation address for the network bridge's IP, not compatible with -b
  -D, --debug=false                          Enable debug mode
  -d, --daemon=false                         Enable daemon mode
  --dns=[]                                   Force Docker to use specific DNS servers
  --dns-search=[]                            Force Docker to use specific DNS search domains
  -e, --exec-driver="native"                 Force the Docker runtime to use a specific exec driver

... etc ...

The –dns is what I want to pass, it shows a ‘list’ with the [], which after much trial and error I finally got this to work:

  • IBM/secure-gateway-client docker run with the --F (acl file) option
  • Jenkins Dockerfile - unable to prepare context: unable to evaluate symlinks in Dockerfile
  • Security of Docker as it runs as root user
  • 502 Bad gateway error/NameError in Rack application for sinatra app on nginx, passenger in a docker container
  • Docker: MacOSX Expose Container ports to host machine
  • Why systemd process running in docker container with PID 1 not forwarding SIGTERM to child processes on docker stop
  • --dns --dns

    which deposits :


    in to the /etc/resolv.conf file.

    Is this the correct way to provide a list to docker (and presumably any go) program?

  • Why does SSH need a passphrase for a passphrase-less key?
  • docker swarm init could not choose an IP address error
  • No 'Access-Control-Allow-Origin' header present - Docker remote API
  • cron task in docker container not being executed
  • How to start docker-machine on OSX?
  • How to use MariaDB in Docker?
  • One Solution collect form web for “docker command line list arguments”

    This is a way of passing multiple arguments to a program in Go but certainly not the only way. This is accomplished by defining a type that implements the Value interface. The flag package on flag.Parse() iterates though the argument list matching the name to a registered Value and calling the Set(string) function on the Value. You can use this to append each value of a given name to a slice.

    type numList []int
    func (l *numList) String() string {
       return "[]"
    func (l *numList) Set(value string) error {
        number, err := strconv.Atoi(value)
        if err != nil {
            return fmt.Errorf("Unable to parse number from value \"%s\"", value)
        *l = append(*l, number)
        return nil

    This new type can be registered as a flag variable. In the following example the application takes n num command line arguments that are converted to an integer and added to a list.

    var numbers numList
    func main() {
        flag.Var(&numbers, "num", "A number to add to the summation"
        sum := 0
        for _, num := range numbers {
           sum += num
        fmt.Printf("The sum of your flag arguments is %d.\n", sum)

    This could have been easily done with a string flag and have users pass a delimited list. There is no established convention within the Go language and each application can provide whatever implementation of best fit.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.