The Docker CLI
Go to file
Sebastiaan van Stijn dbdf8f6468
Preserve sort-order of extra hosts, and allow duplicate entries
Extra hosts (`extra_hosts` in compose-file, or `--hosts` in services) adds
custom host/ip mappings to the container's `/etc/hosts`.

The current implementation used a `map[string]string{}` as intermediate
storage, and sorted the results alphabetically when converting to a service-spec.

As a result, duplicate hosts were removed, and order of host/ip mappings was not
preserved (in case the compose-file used a list instead of a map).

According to the **host.conf(5)** man page (http://man7.org/linux/man-pages/man5/host.conf.5.html)

    multi  Valid values are on and off.  If set to on, the resolver
      library will return all valid addresses for a host that
      appears in the /etc/hosts file, instead of only the first.
      This is off by default, as it may cause a substantial
      performance loss at sites with large hosts files.

Multiple entries for a host are allowed, and even required for some situations,
for example, to add mappings for IPv4 and IPv6 addreses for a host, as illustrated
by the example hosts file in the **hosts(5)** man page (http://man7.org/linux/man-pages/man5/hosts.5.html):

    # The following lines are desirable for IPv4 capable hosts
    127.0.0.1       localhost

    # 127.0.1.1 is often used for the FQDN of the machine
    127.0.1.1       thishost.mydomain.org  thishost
    192.168.1.10    foo.mydomain.org       foo
    192.168.1.13    bar.mydomain.org       bar
    146.82.138.7    master.debian.org      master
    209.237.226.90  www.opensource.org

    # The following lines are desirable for IPv6 capable hosts
    ::1             localhost ip6-localhost ip6-loopback
    ff02::1         ip6-allnodes
    ff02::2         ip6-allrouters

This patch changes the intermediate storage format to use a `[]string`, and only
sorts entries if the input format in the compose file is a mapping. If the input
format is a list, the original sort-order is preserved.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-30 01:48:09 +01:00
.github Fix GitHub spelling 2017-10-05 01:14:31 +08:00
cli Preserve sort-order of extra hosts, and allow duplicate entries 2017-10-30 01:48:09 +01:00
cmd/docker Update code for upstream cobra 2017-10-25 14:49:26 -04:00
contrib/completion Merge pull request #611 from albers/completion-stack-deploy--resolve-image 2017-10-11 22:28:51 +02:00
dockerfiles Merge pull request #633 from seemethere/switch_to_multi_arch_images 2017-10-26 17:08:08 -07:00
docs Adds unpause output to docs 2017-10-26 23:55:03 -07:00
e2e Fix stdout and errors in image/trust 2017-10-23 13:54:55 -04:00
experimental Fix Markdown formatting of experimental "stacks" 2017-06-20 15:15:08 -07:00
internal/test tests: address review feedback 2017-09-25 09:38:41 -07:00
man Fix nocopy description 2017-09-20 16:43:15 +02:00
opts Add nakedret linter. 2017-10-12 11:48:51 -04:00
scripts Update e2e test for image pull to check stdout 2017-10-10 17:04:49 -04:00
service/logs Use a local copy of ParseLogDetails 2017-09-07 12:50:25 -04:00
templates Fix GitHub spelling 2017-10-05 01:14:31 +08:00
vendor Merge pull request #621 from charrywanganthony/displaystringutils 2017-10-27 11:08:36 +02:00
.dockerignore make go build and docker build operations faster 2017-04-27 15:06:57 -07:00
.gitignore Add scripts and targets for manpages and yamldocs 2017-06-05 19:10:44 +00:00
CONTRIBUTING.md Add Contribution guidelines 2017-07-28 11:33:19 -07:00
Jenkinsfile Add a Jenkinsfile 2017-08-16 10:46:43 -04:00
LICENSE Add project files 2017-04-17 17:49:33 -04:00
MAINTAINERS Fix GitHub spelling 2017-10-05 01:14:31 +08:00
Makefile Add a way to just build windows and osx 2017-09-19 16:48:31 -07:00
NOTICE Add project files 2017-04-17 17:49:33 -04:00
README.md Add jenkins build status to readme 2017-09-15 15:08:28 +02:00
TESTING.md Add TESTING document. 2017-08-24 14:45:50 -04:00
VERSION Bump version to 17.11.0-dev 2017-09-30 00:59:27 +02:00
circle.yml Set DISABLE_WARN_OUTSIDE_CONTAINER in the Dockerfile so that we don't spend 10s sleeping in CI 2017-08-15 14:34:43 -04:00
codecov.yml Update codecov project threshold to 15% 2017-06-07 13:26:24 +02:00
docker.Makefile Add a way to just build windows and osx 2017-09-19 16:48:31 -07:00
gometalinter.json Update gometalinter 2017-10-26 12:21:02 -04:00
poule.yml Add github templates and initial poule configuration 2017-05-09 16:57:46 +02:00
vendor.conf Merge pull request #621 from charrywanganthony/displaystringutils 2017-10-27 11:08:36 +02:00

README.md

build status Build Status

docker/cli

This repository is the home of the cli used in the Docker CE and Docker EE products.

Development

docker/cli is developed using Docker.

Build a linux binary:

$ make -f docker.Makefile binary

Build binaries for all supported platforms:

$ make -f docker.Makefile cross

Run all linting:

$ make -f docker.Makefile lint

List all the available targets:

$ make help

In-container development environment

Start an interactive development environment:

$ make -f docker.Makefile shell

In the development environment you can run many tasks, including build binaries:

$ make binary

Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Docker may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

docker/cli is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.