Add better ".git" detection and use

This way, packagers can set GIT_DIR appropriately if they'd prefer to not have ".git" inside their working directory.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
devicemapper: Fix tests on fedora

If /dev/loop-control exists on the system running the test then
ioctlLoopCtlGetFree() will be called, but if not it won't.  It does
not exist in the standard docker build environment, so the tests
currently require this to not be called. This makes it instead
optional, allowing the tests to run on e.g. Fedora.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
devmapper: Fix shutdown warnings

Shutdown contains debug warnings like:

[debug] deviceset.go:699 [deviceset docker-0:33-17945897] waitRemove(/dev/mapper/docker-0:33-17945897-pool)
[debug] deviceset.go:380 libdevmapper(3): libdm-common.c:552 (-1) Device /dev/mapper/docker-0:33-17945897-pool not found

This is because shutdown is using removeDeviceAndWait() to remove the pool device and the
wait part fails because the pool is gone.

We fix this by adding a pool specific removal function which avoids all the trickiness of the
normal remove.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
devmapper: Remove byHash hack

We no longer pass "pool" anywhere that uses byHash() per the last
commit, so we can now remove this hack.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Ensure docker cp stream is closes properly
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Fix bogus variable reference in mkimage-yum.sh

Fixes this: https://github.com/dotcloud/docker/commit/d419da7227826e84e9375ece4fd9d4978a42cbf7#commitcomment-5344982

Docker-DCO-1.1-Signed-off-by: Chris St. Pierre <chris.a.st.pierre@gmail.com> (github: stpierre)
Avoid extra mount/unmount during build

CmdRun() calls first run() and then wait() to wait for it to exit,
then it runs commit(). The run command will mount the container and
the container exiting will unmount it. Then the commit will
immediately mount it again to do a diff.

This seems minor, but this is actually problematic, as the Get/Put
pair will create a spurious mount/unmount cycle that is not needed and
slows things down. Additionally it will create a supurious
devicemapper activate/deactivate cycle that causes races with udev as
seen in https://github.com/dotcloud/docker/issues/4036.

To ensure that we only unmount once we split up run() into create()
and run() and reference the mount until after the commit().

With this change docker build on devicemapper is now race-free, and
slightly faster.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
add error to docekr build --rm

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
(resubmit) Add notes about OS/X and remote daemons

Docker-DCO-1.1-Signed-off-by: Charles Merriam <charles.merriam@gmail.com> (github: merriam)
Minor error in example code (resubmit #4109)

Docker-DCO-1.1-Signed-off-by: Charles Merriam <charles.merriam@gmail.com> (github: merriam)
Merge pull request #4112 from merriam/patch-3

(resubmit #4110) Add notes about OS/X and remote daemons
Merge pull request #4111 from merriam/patch-4

Minor error in example code (resubmit #4109)
disallow tcp:// from defaulting to 127.0.0.1:4243

This stops docker from accepting tcp:// as a valid bind address.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Merge pull request #4073 from crosbymichael/fix-docker-cp-close

Ensure docker cp stream is closed properly
Merge pull request #4056 from alexlarsson/fix-devmapper-test

devicemapper: Fix tests on fedora
Merge pull request #4043 from tianon/hack-git-detection-and-use

Add better ".git" detection and use
Merge pull request #4096 from alexlarsson/fix-devmapper-race-2

Avoid extra mount/unmount during build
Image tag  endpoint doc typo.

Docker-DCO-1.1-Signed-off-by: Pedro Dias <petermdias@gmail.com> (github: apocas)
remove unneeded sysctl changes in sysvinit-redhat init script

Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)
Merge pull request #4103 from vieux/add_error_build-rm

add error to docker build --rm