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:

  • Setting up drupal with docker using two containers? nginx and mariadb
  • Canonical Way to Connect to Service on Host from Docker Container
  • Docker - Telnet from container to host
  • Docker stuck after running background process and detach it
  • dockerize a wpf application and use it
  • Jenkins store workspace outside docker container
  • --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?

  • Docker API can’t apply json filters
  • Docker separation of processes and source code control
  • How install java to ubuntu on docker?
  • Docker pull error
  • Explanation about Supervisor and tail over Apache's error.log
  • How to run a python-flask container on Mac OS?
  • 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.