From 0dbee8869441982cdfe70d9358ad46028e7451aa Mon Sep 17 00:00:00 2001
From: Andrew Hsu <andrewhsu@docker.com>
Date: Tue, 6 Jun 2017 08:39:39 +0000
Subject: [PATCH] generate man pages

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
(cherry picked from commit e14fca86f8230e10d79a7bfae2873a98a16bb44d)
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
---
 components/packaging/deb/Makefile               | 16 ++++++++--------
 components/packaging/deb/common/rules           |  3 +--
 .../deb/debian-jessie/Dockerfile.armv7l         |  4 +---
 .../deb/debian-jessie/Dockerfile.x86_64         |  4 +---
 .../deb/debian-stretch/Dockerfile.armv7l        |  4 +---
 .../deb/debian-stretch/Dockerfile.x86_64        |  4 +---
 .../deb/debian-wheezy/Dockerfile.armv7l         |  4 +---
 .../deb/debian-wheezy/Dockerfile.x86_64         |  4 +---
 .../deb/ubuntu-trusty/Dockerfile.armv7l         |  4 +---
 .../deb/ubuntu-trusty/Dockerfile.x86_64         |  4 +---
 .../deb/ubuntu-xenial/Dockerfile.armv7l         |  4 +---
 .../deb/ubuntu-xenial/Dockerfile.x86_64         |  4 +---
 .../deb/ubuntu-yakkety/Dockerfile.armv7l        |  4 +---
 .../deb/ubuntu-yakkety/Dockerfile.x86_64        |  4 +---
 .../deb/ubuntu-zesty/Dockerfile.armv7l          |  4 +---
 .../deb/ubuntu-zesty/Dockerfile.x86_64          |  4 +---
 components/packaging/rpm/Makefile               |  8 ++++----
 .../packaging/rpm/centos-7/Dockerfile.x86_64    |  2 +-
 .../packaging/rpm/centos-7/docker-ce.spec       | 17 ++++++++---------
 .../packaging/rpm/fedora-24/Dockerfile.x86_64   |  4 ++--
 .../packaging/rpm/fedora-24/docker-ce.spec      | 17 ++++++++---------
 .../packaging/rpm/fedora-25/Dockerfile.x86_64   |  4 ++--
 .../packaging/rpm/fedora-25/docker-ce.spec      | 17 ++++++++---------
 23 files changed, 56 insertions(+), 88 deletions(-)

diff --git a/components/packaging/deb/Makefile b/components/packaging/deb/Makefile
index 5ca2b57f62a..da14480fcaf 100644
--- a/components/packaging/deb/Makefile
+++ b/components/packaging/deb/Makefile
@@ -6,7 +6,7 @@ CLI_DIR:=$(CURDIR)/../../cli
 GITCOMMIT?=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD)
 VERSION?=$(shell cat $(ENGINE_DIR)/VERSION)
 DOCKER_EXPERIMENTAL:=0
-CHOWN:=docker run --rm -v $(CURDIR):/v -w /v $(ALPINE) chown
+CHOWN:=docker run --rm -i -t -v $(CURDIR):/v -w /v $(ALPINE) chown
 
 .PHONY: help clean deb ubuntu debian ubuntu-xenial ubuntu-trusty ubuntu-yakkety ubuntu-zesty debian-jessie debian-stretch debian-wheezy
 
@@ -25,7 +25,7 @@ debian: debian-stretch debian-wheezy debian-jessie ## build all debian deb packa
 
 ubuntu-xenial: ## build ubuntu xenial deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -36,7 +36,7 @@ ubuntu-xenial: ## build ubuntu xenial deb packages
 
 ubuntu-trusty: ## build ubuntu trusty deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -47,7 +47,7 @@ ubuntu-trusty: ## build ubuntu trusty deb packages
 
 ubuntu-yakkety: ## build ubuntu yakkety deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -58,7 +58,7 @@ ubuntu-yakkety: ## build ubuntu yakkety deb packages
 
 ubuntu-zesty: ## build ubuntu zesty deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -69,7 +69,7 @@ ubuntu-zesty: ## build ubuntu zesty deb packages
 
 debian-jessie: ## build debian jessie deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -80,7 +80,7 @@ debian-jessie: ## build debian jessie deb packages
 
 debian-stretch: ## build debian stretch deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
@@ -91,7 +91,7 @@ debian-stretch: ## build debian stretch deb packages
 
 debian-wheezy: ## build debian wheezy deb packages
 	docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
-	docker run --rm \
+	docker run --rm -i -t \
 		-e VERSION=$(VERSION) \
 		-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
 		-v $(CURDIR)/debbuild/$@:/build \
diff --git a/components/packaging/deb/common/rules b/components/packaging/deb/common/rules
index 9a9ed979f0d..3d16fc476eb 100644
--- a/components/packaging/deb/common/rules
+++ b/components/packaging/deb/common/rules
@@ -12,8 +12,7 @@ override_dh_gencontrol:
 
 override_dh_auto_build:
 	cd engine && ./hack/make.sh dynbinary
-	LDFLAGS='' make -C cli VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary
-	# ./man/md2man-all.sh runs outside the build container (if at all), since we don't have go-md2man here
+	LDFLAGS='' make -C cli VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages
 
 override_dh_auto_test:
 	./engine/bundles/$(BUNDLE_VERSION)/dynbinary-daemon/dockerd -v
diff --git a/components/packaging/deb/debian-jessie/Dockerfile.armv7l b/components/packaging/deb/debian-jessie/Dockerfile.armv7l
index f7fca14e95b..338958feca1 100644
--- a/components/packaging/deb/debian-jessie/Dockerfile.armv7l
+++ b/components/packaging/deb/debian-jessie/Dockerfile.armv7l
@@ -8,10 +8,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/debian-jessie/Dockerfile.x86_64 b/components/packaging/deb/debian-jessie/Dockerfile.x86_64
index d44c7955dec..36892a8c856 100644
--- a/components/packaging/deb/debian-jessie/Dockerfile.x86_64
+++ b/components/packaging/deb/debian-jessie/Dockerfile.x86_64
@@ -8,10 +8,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/debian-stretch/Dockerfile.armv7l b/components/packaging/deb/debian-stretch/Dockerfile.armv7l
index d50d2abd6ee..f173cfd4656 100644
--- a/components/packaging/deb/debian-stretch/Dockerfile.armv7l
+++ b/components/packaging/deb/debian-stretch/Dockerfile.armv7l
@@ -8,10 +8,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/deb/debian-stretch/Dockerfile.x86_64 b/components/packaging/deb/debian-stretch/Dockerfile.x86_64
index c6ed8a93c5f..a4369a2f5ad 100644
--- a/components/packaging/deb/debian-stretch/Dockerfile.x86_64
+++ b/components/packaging/deb/debian-stretch/Dockerfile.x86_64
@@ -8,10 +8,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/deb/debian-wheezy/Dockerfile.armv7l b/components/packaging/deb/debian-wheezy/Dockerfile.armv7l
index 4c990d2d255..8a838b68ecd 100644
--- a/components/packaging/deb/debian-wheezy/Dockerfile.armv7l
+++ b/components/packaging/deb/debian-wheezy/Dockerfile.armv7l
@@ -10,10 +10,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion  build-essenti
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/debian-wheezy/Dockerfile.x86_64 b/components/packaging/deb/debian-wheezy/Dockerfile.x86_64
index c7627b27fb5..fac9229d61a 100644
--- a/components/packaging/deb/debian-wheezy/Dockerfile.x86_64
+++ b/components/packaging/deb/debian-wheezy/Dockerfile.x86_64
@@ -10,10 +10,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion  build-essenti
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/ubuntu-trusty/Dockerfile.armv7l b/components/packaging/deb/ubuntu-trusty/Dockerfile.armv7l
index b766b5cf6c1..b39912c706c 100644
--- a/components/packaging/deb/ubuntu-trusty/Dockerfile.armv7l
+++ b/components/packaging/deb/ubuntu-trusty/Dockerfile.armv7l
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/ubuntu-trusty/Dockerfile.x86_64 b/components/packaging/deb/ubuntu-trusty/Dockerfile.x86_64
index cde9ca847d7..a15a0633f6b 100644
--- a/components/packaging/deb/ubuntu-trusty/Dockerfile.x86_64
+++ b/components/packaging/deb/ubuntu-trusty/Dockerfile.x86_64
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/ubuntu-xenial/Dockerfile.armv7l b/components/packaging/deb/ubuntu-xenial/Dockerfile.armv7l
index 4946f4b70a0..d51ffa6b529 100644
--- a/components/packaging/deb/ubuntu-xenial/Dockerfile.armv7l
+++ b/components/packaging/deb/ubuntu-xenial/Dockerfile.armv7l
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/deb/ubuntu-xenial/Dockerfile.x86_64 b/components/packaging/deb/ubuntu-xenial/Dockerfile.x86_64
index bb622e7d51e..a914e789a0a 100644
--- a/components/packaging/deb/ubuntu-xenial/Dockerfile.x86_64
+++ b/components/packaging/deb/ubuntu-xenial/Dockerfile.x86_64
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/deb/ubuntu-yakkety/Dockerfile.armv7l b/components/packaging/deb/ubuntu-yakkety/Dockerfile.armv7l
index f729e9283da..4cb50aa32cd 100644
--- a/components/packaging/deb/ubuntu-yakkety/Dockerfile.armv7l
+++ b/components/packaging/deb/ubuntu-yakkety/Dockerfile.armv7l
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/ubuntu-yakkety/Dockerfile.x86_64 b/components/packaging/deb/ubuntu-yakkety/Dockerfile.x86_64
index 1f75a9de14a..31b53256bc3 100644
--- a/components/packaging/deb/ubuntu-yakkety/Dockerfile.x86_64
+++ b/components/packaging/deb/ubuntu-yakkety/Dockerfile.x86_64
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
 ENV RUNC_BUILDTAGS apparmor selinux
 
diff --git a/components/packaging/deb/ubuntu-zesty/Dockerfile.armv7l b/components/packaging/deb/ubuntu-zesty/Dockerfile.armv7l
index 1a7d35d9de5..c54495016bf 100644
--- a/components/packaging/deb/ubuntu-zesty/Dockerfile.armv7l
+++ b/components/packaging/deb/ubuntu-zesty/Dockerfile.armv7l
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/deb/ubuntu-zesty/Dockerfile.x86_64 b/components/packaging/deb/ubuntu-zesty/Dockerfile.x86_64
index e9ece83f38a..954bbe1b9f0 100644
--- a/components/packaging/deb/ubuntu-zesty/Dockerfile.x86_64
+++ b/components/packaging/deb/ubuntu-zesty/Dockerfile.x86_64
@@ -4,10 +4,8 @@ RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools bu
 
 ENV GO_VERSION 1.8.3
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-
 ENV GOPATH /go
-
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
 ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS apparmor seccomp selinux
 
diff --git a/components/packaging/rpm/Makefile b/components/packaging/rpm/Makefile
index 2f6b015a216..a52f9276502 100644
--- a/components/packaging/rpm/Makefile
+++ b/components/packaging/rpm/Makefile
@@ -5,8 +5,8 @@ GITCOMMIT=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD)
 VERSION=$(shell cat $(ENGINE_DIR)/VERSION)
 DOCKER_EXPERIMENTAL=0
 GEN_RPM_VER=$(shell ./gen-rpm-ver $(ENGINE_DIR) $(VERSION))
-CHOWN=docker run --rm -v $(CURDIR):/v -w /v alpine chown
-RPMBUILD=docker run --privileged --rm \
+CHOWN=docker run --rm -i -t -v $(CURDIR):/v -w /v alpine chown
+RPMBUILD=docker run --privileged --rm -i -t \
 	-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES \
 	-v $(CURDIR)/rpmbuild/BUILD:/root/rpmbuild/BUILD \
 	-v $(CURDIR)/rpmbuild/BUILDROOT:/root/rpmbuild/BUILDROOT \
@@ -52,7 +52,7 @@ centos-7: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build centos-7
 
 rpmbuild/SOURCES/cli.tgz:
 	mkdir -p rpmbuild/SOURCES
-	docker run --rm -w /v \
+	docker run --rm -i -t -w /v \
 		-v $(CLI_DIR):/cli \
 		-v $(CURDIR)/rpmbuild/SOURCES:/v \
 		alpine \
@@ -60,7 +60,7 @@ rpmbuild/SOURCES/cli.tgz:
 
 rpmbuild/SOURCES/engine.tgz:
 	mkdir -p rpmbuild/SOURCES
-	docker run --rm -w /v \
+	docker run --rm -i -t -w /v \
 		-v $(ENGINE_DIR):/engine \
 		-v $(CURDIR)/rpmbuild/SOURCES:/v \
 		alpine \
diff --git a/components/packaging/rpm/centos-7/Dockerfile.x86_64 b/components/packaging/rpm/centos-7/Dockerfile.x86_64
index dd6c9da1c10..9e2c5591538 100644
--- a/components/packaging/rpm/centos-7/Dockerfile.x86_64
+++ b/components/packaging/rpm/centos-7/Dockerfile.x86_64
@@ -17,7 +17,7 @@ RUN yum install -y \
    rpmdevtools \
    vim-common
 
-ENV GO_VERSION 1.7.5
+ENV GO_VERSION 1.8.3
 ENV DISTRO centos
 ENV SUITE 7
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
diff --git a/components/packaging/rpm/centos-7/docker-ce.spec b/components/packaging/rpm/centos-7/docker-ce.spec
index 449eb67b82f..e1550590595 100644
--- a/components/packaging/rpm/centos-7/docker-ce.spec
+++ b/components/packaging/rpm/centos-7/docker-ce.spec
@@ -55,14 +55,13 @@ export DOCKER_GITCOMMIT=%{_gitcommit}
 mkdir -p /go/src/github.com/docker
 rm -f /go/src/github.com/docker/cli
 ln -s /root/rpmbuild/BUILD/src/cli /go/src/github.com/docker/cli
-pushd cli
-make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary # cli
+pushd /go/src/github.com/docker/cli
+make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli
 popd
 pushd engine
 TMP_GOPATH="/go" hack/dockerfile/install-binaries.sh runc-dynamic containerd-dynamic proxy-dynamic tini
 hack/make.sh dynbinary
 popd
-# ./man/md2man-all.sh runs outside the build container (if at all), since we don't have go-md2man here
 
 %check
 cli/build/docker -v
@@ -107,11 +106,11 @@ install -p -m 644 engine/contrib/completion/fish/docker.fish $RPM_BUILD_ROOT/usr
 
 # install manpages
 install -d %{buildroot}%{_mandir}/man1
-#install -p -m 644 man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
+install -p -m 644 cli/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
 install -d %{buildroot}%{_mandir}/man5
-#install -p -m 644 man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
+install -p -m 644 cli/man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
 install -d %{buildroot}%{_mandir}/man8
-#install -p -m 644 man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
+install -p -m 644 cli/man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
 
 # add vimfiles
 install -d $RPM_BUILD_ROOT/usr/share/vim/vimfiles/doc
@@ -142,9 +141,9 @@ install -p -m 644 engine/contrib/syntax/nano/Dockerfile.nanorc $RPM_BUILD_ROOT/u
 /usr/share/zsh/vendor-completions/_docker
 /usr/share/fish/vendor_completions.d/docker.fish
 %doc
-#/%{_mandir}/man1/*
-#/%{_mandir}/man5/*
-#/%{_mandir}/man8/*
+/%{_mandir}/man1/*
+/%{_mandir}/man5/*
+/%{_mandir}/man8/*
 /usr/share/vim/vimfiles/doc/dockerfile.txt
 /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
 /usr/share/vim/vimfiles/syntax/dockerfile.vim
diff --git a/components/packaging/rpm/fedora-24/Dockerfile.x86_64 b/components/packaging/rpm/fedora-24/Dockerfile.x86_64
index 569442689e9..90ffe353ea3 100644
--- a/components/packaging/rpm/fedora-24/Dockerfile.x86_64
+++ b/components/packaging/rpm/fedora-24/Dockerfile.x86_64
@@ -6,9 +6,9 @@ ENV GO_VERSION 1.8.3
 ENV DISTRO fedora
 ENV SUITE 24
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-ENV AUTO_GOPATH 1
 ENV GOPATH /go
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
+ENV AUTO_GOPATH 1
 ENV DOCKER_BUILDTAGS pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS seccomp selinux
 RUN mkdir -p /go/src/github.com/docker && mkdir -p /go/src/github.com/opencontainers
diff --git a/components/packaging/rpm/fedora-24/docker-ce.spec b/components/packaging/rpm/fedora-24/docker-ce.spec
index d40fa67cb00..bd17ae5dcfb 100644
--- a/components/packaging/rpm/fedora-24/docker-ce.spec
+++ b/components/packaging/rpm/fedora-24/docker-ce.spec
@@ -55,14 +55,13 @@ export DOCKER_GITCOMMIT=%{_gitcommit}
 mkdir -p /go/src/github.com/docker
 rm -f /go/src/github.com/docker/cli
 ln -s /root/rpmbuild/BUILD/src/cli /go/src/github.com/docker/cli
-pushd cli
-make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary # cli
+pushd /go/src/github.com/docker/cli
+make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli
 popd
 pushd engine
 TMP_GOPATH="/go" hack/dockerfile/install-binaries.sh runc-dynamic containerd-dynamic proxy-dynamic tini
 hack/make.sh dynbinary
 popd
-# ./man/md2man-all.sh runs outside the build container (if at all), since we don't have go-md2man here
 
 %check
 cli/build/docker -v
@@ -107,11 +106,11 @@ install -p -m 644 engine/contrib/completion/fish/docker.fish $RPM_BUILD_ROOT/usr
 
 # install manpages
 install -d %{buildroot}%{_mandir}/man1
-#install -p -m 644 man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
+install -p -m 644 cli/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
 install -d %{buildroot}%{_mandir}/man5
-#install -p -m 644 man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
+install -p -m 644 cli/man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
 install -d %{buildroot}%{_mandir}/man8
-#install -p -m 644 man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
+install -p -m 644 cli/man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
 
 # add vimfiles
 install -d $RPM_BUILD_ROOT/usr/share/vim/vimfiles/doc
@@ -142,9 +141,9 @@ install -p -m 644 engine/contrib/syntax/nano/Dockerfile.nanorc $RPM_BUILD_ROOT/u
 /usr/share/zsh/vendor-completions/_docker
 /usr/share/fish/vendor_completions.d/docker.fish
 %doc
-#/%{_mandir}/man1/*
-#/%{_mandir}/man5/*
-#/%{_mandir}/man8/*
+/%{_mandir}/man1/*
+/%{_mandir}/man5/*
+/%{_mandir}/man8/*
 /usr/share/vim/vimfiles/doc/dockerfile.txt
 /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
 /usr/share/vim/vimfiles/syntax/dockerfile.vim
diff --git a/components/packaging/rpm/fedora-25/Dockerfile.x86_64 b/components/packaging/rpm/fedora-25/Dockerfile.x86_64
index ad737ce5ac8..4d231bb14bc 100644
--- a/components/packaging/rpm/fedora-25/Dockerfile.x86_64
+++ b/components/packaging/rpm/fedora-25/Dockerfile.x86_64
@@ -6,9 +6,9 @@ ENV GO_VERSION 1.8.3
 ENV DISTRO fedora
 ENV SUITE 25
 RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
-ENV PATH $PATH:/usr/local/go/bin
-ENV AUTO_GOPATH 1
 ENV GOPATH /go
+ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
+ENV AUTO_GOPATH 1
 ENV DOCKER_BUILDTAGS pkcs11 seccomp selinux
 ENV RUNC_BUILDTAGS seccomp selinux
 RUN mkdir -p /go/src/github.com/docker && mkdir -p /go/src/github.com/opencontainers
diff --git a/components/packaging/rpm/fedora-25/docker-ce.spec b/components/packaging/rpm/fedora-25/docker-ce.spec
index c1727180346..32c4315f581 100644
--- a/components/packaging/rpm/fedora-25/docker-ce.spec
+++ b/components/packaging/rpm/fedora-25/docker-ce.spec
@@ -54,14 +54,13 @@ export DOCKER_GITCOMMIT=%{_gitcommit}
 mkdir -p /go/src/github.com/docker
 rm -f /go/src/github.com/docker/cli
 ln -s /root/rpmbuild/BUILD/src/cli /go/src/github.com/docker/cli
-pushd cli
-make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary # cli
+pushd /go/src/github.com/docker/cli
+make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli
 popd
 pushd engine
 TMP_GOPATH="/go" hack/dockerfile/install-binaries.sh runc-dynamic containerd-dynamic proxy-dynamic tini
 hack/make.sh dynbinary
 popd
-# ./man/md2man-all.sh runs outside the build container (if at all), since we don't have go-md2man here
 
 %check
 cli/build/docker -v
@@ -106,11 +105,11 @@ install -p -m 644 engine/contrib/completion/fish/docker.fish $RPM_BUILD_ROOT/usr
 
 # install manpages
 install -d %{buildroot}%{_mandir}/man1
-#install -p -m 644 man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
+install -p -m 644 cli/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
 install -d %{buildroot}%{_mandir}/man5
-#install -p -m 644 man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
+install -p -m 644 cli/man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
 install -d %{buildroot}%{_mandir}/man8
-#install -p -m 644 man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
+install -p -m 644 cli/man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8
 
 # add vimfiles
 install -d $RPM_BUILD_ROOT/usr/share/vim/vimfiles/doc
@@ -141,9 +140,9 @@ install -p -m 644 engine/contrib/syntax/nano/Dockerfile.nanorc $RPM_BUILD_ROOT/u
 /usr/share/zsh/vendor-completions/_docker
 /usr/share/fish/vendor_completions.d/docker.fish
 %doc
-#/%{_mandir}/man1/*
-#/%{_mandir}/man5/*
-#/%{_mandir}/man8/*
+/%{_mandir}/man1/*
+/%{_mandir}/man5/*
+/%{_mandir}/man8/*
 /usr/share/vim/vimfiles/doc/dockerfile.txt
 /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
 /usr/share/vim/vimfiles/syntax/dockerfile.vim