Add mention of e2fsprogs to runtime dependencies.

Signed-off-by: Marc Tamsky <mtamsky@gmail.com> (github: tamsky)
Updated the COPY directive reference: Source can't be a URL for COPY (+ formatting error fixes)

Signed-off-by: Roman Dudin <katrmr@gmail.com>
Support hairpin NAT

This re-applies commit b39d02b with additional iptables rules to solve the issue with containers routing back into themselves.

The previous issue with this attempt was that the DNAT rule would send traffic back into the container it came from. When this happens you have 2 issues.
1) reverse path filtering. The container is going to see the traffic coming in from the outside and it's going to have a source address of itself. So reverse path filtering will kick in and drop the packet.
2) direct return mismatch. Assuming you turned reverse path filtering off, when the packet comes back in, it's goign to have a source address of itself, thus when the reply traffic is sent, it's going to have a source address of itself. But the original packet was sent to the host IP address, so the traffic will be dropped because it's coming from an address which the original traffic was not sent to (and likely with an incorrect port as well).

The solution to this is to masquerade the traffic when it gets routed back into the origin container. However for this to work you need to enable hairpin mode on the bridge port, otherwise the kernel will just drop the traffic.
The hairpin mode set is part of libcontainer, while the MASQ change is part of docker.

This reverts commit 63c303eecdbaf4dc7967fd51b82cd447c778cecc.

Docker-DCO-1.1-Signed-off-by: Patrick Hemmer <patrick.hemmer@gmail.com> (github: phemmer)
Add check for IP_NF_FILTER

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
devmapper: Move file write and rename functionality in a separate function

Currently we save device metadata and have a helper function saveMetadata()
which converts data in json format as well as saves it to file. For
converting data in json format, one needs to know what is being saved.

Break this function down in two functions. One function only has file
write capability and takes in argument about byte array of json data.
Now this function does not have to know what data is being saved. It
only knows about a stream of json data is being saved to a file.

This allows me to reuse this function to save a different type of
metadata. In this case I am planning to save NextDeviceId so that
docker can use this device Id upon next restart. Otherwise docker
starts from 0 which is suboptimal.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
devmapper: Export nextDeviceId so that json.Marshal() can operate on it

I was trying to save nextDeviceId to a file but it would not work and
json.Marshal() will do nothing. Then some search showed that I need to
make first letter of struct field capital, exporting this field and
now json.Marshal() works.

This is a preparatory patch for the next one.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
devmapper: Save and restore NextDeviceId in a file

The way thin-pool right now is designed, user space is supposed to keep
track of what device ids have already been used. If user space tries to
create a new thin/snap device and device id has already been used, thin
pool retuns -EEXIST.

Upon receiving -EEXIST, current docker implementation simply tries the
NextDeviceId++ and keeps on doing this till it finds a free device id.

This approach has two issues.

- It is little suboptimal.
- If device id already exists, current kenrel implementation spits out
  a messsage on console.

[17991.140135] device-mapper: thin: Creation of new snapshot 33 of device 3 failed.

Here kenrel is trying to tell user that device id 33 has already been used.
And this shows up for every device id docker tries till it reaches a point
where device ids are not used. So if there are thousands of container and
one is trying to create a new container after fresh docker start, expect
thousands of such warnings to flood console.

This patch saves the NextDeviceId in a file in
/var/lib/docker/devmapper/metadata/deviceset-metadata and reads it back
when docker starts. This way we don't retry lots of device ids which 
have already been used. 

There might be some device ids which are free but we will get back to them
once device numbers wrap around (24bit limit on device ids).

This patch should cut down on number of kernel warnings.

Notice that I am creating a deviceset metadata file which is a global file
for this pool. So down the line if we need to save more data we should be
able to do that.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
devmapper: Fix gofmt related build failures

My pull request failed the build due to gofmat issues. I have run gofmt
on specified files and this commit fixes it.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
devicemapper: split out devicemapper bindings

This is a first pass at splitting out devicemapper into separate, usable
bindings.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
docker-remove-redundant-json-tags

In previous patch I had introduce json:"-" tags to be on safer side to make
sure certain fields are not marshalled/unmarshalled. But struct fields
starting with small letter are not exported so they will not be marshalled
anyway. So remove json:"-" tags from there.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Not fail on updating parent links

Fixes #8796

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
Fix Docker Hub tags list specification

The current implementation of the Docker Hub returns a list of objects
containing the tag name and the layer id.

Docker-DCO-1.1-Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
pkg/mount: mountinfo from specified pid

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Merge pull request #8931 from vbatts/vbatts-mount_pid_mountinfo

pkg/mount: mountinfo from specified pid
Revise Docs Maintainers list

Removing Sonat from docs maintainers because he no longer has time to complete all the responsibilities. Many thanks to Sonat for his help.

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
Use the HTTP Last-Modified http header as the mtime value for ADD cmd when present

Closes #8331

Signed-off-by: Doug Davis <dug@us.ibm.com>
vendor: update vendor'd libcontainer version

This patch updates the vendor'd libcontainer version, so that Docker can
take advantage of the updates to the `user` API.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
*: transition to new libcontainer/user API

This patch fixes the compilation errors in Docker due to changes in the
libcontainer/user API. There is no functionality change due to this
patch.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
This patch adds ability in docker to detect out of memory conditions in containers.
Since the containers can handle the out of memory kernel kills gracefully, docker
will only provide out of memory information as an additional metadata as part of
container status.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
Address comments.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)