From 662e248f680eb49a9951a8b34125506b8f82dfed Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Fri, 18 May 2018 10:36:34 -0700 Subject: [PATCH] CE package conversion This splits out the CLI into a discrete package and removes the engine from the engine package. Instead the engine is initialized via a post-inst script using the new CLI UX. --- deb/Makefile | 6 +- deb/build-deb | 13 +- deb/common/control | 29 +++- ...mpletion => docker-ce-cli.bash-completion} | 0 deb/common/docker-ce-cli.install | 2 + ...ker-ce.manpages => docker-ce-cli.manpages} | 0 deb/common/docker-ce.docker.default | 20 --- deb/common/docker-ce.docker.init | 156 ------------------ deb/common/docker-ce.docker.upstart | 72 -------- deb/common/docker-ce.install | 11 -- deb/common/docker-ce.postinst | 4 + deb/common/docker-ce.udev | 3 - deb/common/docs | 2 +- deb/common/rules | 28 +--- 14 files changed, 42 insertions(+), 304 deletions(-) rename deb/common/{docker-ce.bash-completion => docker-ce-cli.bash-completion} (100%) create mode 100644 deb/common/docker-ce-cli.install rename deb/common/{docker-ce.manpages => docker-ce-cli.manpages} (100%) delete mode 100644 deb/common/docker-ce.docker.default delete mode 100644 deb/common/docker-ce.docker.init delete mode 100644 deb/common/docker-ce.docker.upstart delete mode 100644 deb/common/docker-ce.install delete mode 100644 deb/common/docker-ce.udev diff --git a/deb/Makefile b/deb/Makefile index cf1c668c18..39303bd519 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -1,11 +1,10 @@ SHELL:=/bin/bash ARCH:=$(shell uname -m) -ENGINE_DIR:=$(CURDIR)/../../engine CLI_DIR:=$(CURDIR)/../../cli -GITCOMMIT?=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD) +GITCOMMIT?=$(shell cd $(CLI_DIR) && git rev-parse --short HEAD) VERSION?=0.0.0-dev GO_VERSION:=1.10.3 -DEB_VERSION=$(shell ./gen-deb-ver $(ENGINE_DIR) "$(VERSION)") +DEB_VERSION=$(shell ./gen-deb-ver $(CLI_DIR) "$(VERSION)") CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown EPOCH?=2 @@ -16,7 +15,6 @@ RUN=docker run --rm -i \ -e VERSION=$(word 2, $(DEB_VERSION)) \ -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ -v $(CLI_DIR):/cli \ -v $(CURDIR)/systemd:/root/build-deb/systemd \ debbuild-$@/$(ARCH) diff --git a/deb/build-deb b/deb/build-deb index bb25ffdd07..da4eb3f7d0 100755 --- a/deb/build-deb +++ b/deb/build-deb @@ -13,18 +13,9 @@ if [[ -z "$DEB_VERSION" ]]; then exit 1 fi -( - set -e - cd engine - # I want to rip this install-binaries script out so badly - for component in tini "proxy dynamic" "runc all" "containerd dynamic";do - TMP_GOPATH="/go" hack/dockerfile/install/install.sh $component - done -) - echo VERSION AAA $VERSION -VERSION=${VERSION:-$( cat engine/VERSION )} +VERSION=${VERSION:-$( cat cli/VERSION )} echo VERSION bbb $VERSION @@ -40,7 +31,7 @@ EOF # The space above at the start of the line for the debMaintainer is very important # Give the script a git commit because it wants it -export DOCKER_GITCOMMIT=${DOCKER_GITCOMMIT-$($GIT_COMMAND rev-parse --short HEAD)} +export DOCKER_GITCOMMIT=${DOCKER_GITCOMMIT-$(cd cli; $GIT_COMMAND rev-parse --short HEAD)} echo VERSION BBB $VERSION dpkg-buildpackage -uc -us -I.git diff --git a/deb/common/control b/deb/common/control index a12448f1a8..0f23b511d4 100644 --- a/deb/common/control +++ b/deb/common/control @@ -9,8 +9,8 @@ Vcs-Git: git://github.com/docker/docker.git Package: docker-ce Architecture: linux-any -Depends: iptables, ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: aufs-tools, +Depends: docker-ce-cli, containerd, ${shlibs:Depends} +Recommends: abufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, @@ -29,3 +29,28 @@ Description: Docker: the open-source application container engine language, framework or packaging system. That makes them great building blocks for deploying and scaling web apps, databases, and backend services without depending on a particular stack or provider. + +Source: docker-ce-cli +Section: admin +Priority: optional +Maintainer: Docker +Standards-Version: 3.9.6 +Homepage: https://dockerproject.org +Vcs-Browser: https://github.com/docker/cli +Vcs-Git: git://github.com/docker/cli.git +Package: docker-ce-cli +Architecture: linux-any +Depends: ${shlibs:Depends} +Recommends: +Conflicts: docker (<< 1.5~), docker.io, lxc-docker, lxc-docker-virtual-package, docker-engine, docker-engine-cs, docker-ee-cli +Replaces: +Description: Docker CLI: the open-source application container engine + Docker is an open source project to build, ship and run any application as a + lightweight container + . + Docker containers are both hardware-agnostic and platform-agnostic. This means + they can run anywhere, from your laptop to the largest EC2 compute instance and + everything in between - and they don't require you to use a particular + language, framework or packaging system. That makes them great building blocks + for deploying and scaling web apps, databases, and backend services without + depending on a particular stack or provider. diff --git a/deb/common/docker-ce.bash-completion b/deb/common/docker-ce-cli.bash-completion similarity index 100% rename from deb/common/docker-ce.bash-completion rename to deb/common/docker-ce-cli.bash-completion diff --git a/deb/common/docker-ce-cli.install b/deb/common/docker-ce-cli.install new file mode 100644 index 0000000000..caf2498041 --- /dev/null +++ b/deb/common/docker-ce-cli.install @@ -0,0 +1,2 @@ +cli/contrib/completion/fish/docker.fish usr/share/fish/vendor_completions.d/ +cli/contrib/completion/zsh/_docker usr/share/zsh/vendor-completions/ diff --git a/deb/common/docker-ce.manpages b/deb/common/docker-ce-cli.manpages similarity index 100% rename from deb/common/docker-ce.manpages rename to deb/common/docker-ce-cli.manpages diff --git a/deb/common/docker-ce.docker.default b/deb/common/docker-ce.docker.default deleted file mode 100644 index c4e93199b4..0000000000 --- a/deb/common/docker-ce.docker.default +++ /dev/null @@ -1,20 +0,0 @@ -# Docker Upstart and SysVinit configuration file - -# -# THIS FILE DOES NOT APPLY TO SYSTEMD -# -# Please see the documentation for "systemd drop-ins": -# https://docs.docker.com/engine/admin/systemd/ -# - -# Customize location of Docker binary (especially for development testing). -#DOCKERD="/usr/local/bin/dockerd" - -# Use DOCKER_OPTS to modify the daemon startup options. -#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" - -# If you need Docker to use an HTTP proxy, it can also be specified here. -#export http_proxy="http://127.0.0.1:3128/" - -# This is also a handy place to tweak where Docker's temporary files go. -#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp" diff --git a/deb/common/docker-ce.docker.init b/deb/common/docker-ce.docker.init deleted file mode 100644 index 9c8fa6be73..0000000000 --- a/deb/common/docker-ce.docker.init +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh -set -e - -### BEGIN INIT INFO -# Provides: docker -# Required-Start: $syslog $remote_fs -# Required-Stop: $syslog $remote_fs -# Should-Start: cgroupfs-mount cgroup-lite -# Should-Stop: cgroupfs-mount cgroup-lite -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Create lightweight, portable, self-sufficient containers. -# Description: -# Docker is an open-source project to easily create lightweight, portable, -# self-sufficient containers from any application. The same container that a -# developer builds and tests on a laptop can run at scale, in production, on -# VMs, bare metal, OpenStack clusters, public clouds and more. -### END INIT INFO - -export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin - -BASE=docker - -# modify these in /etc/default/$BASE (/etc/default/docker) -DOCKERD=/usr/bin/dockerd -# This is the pid file managed by docker itself -DOCKER_PIDFILE=/var/run/$BASE.pid -# This is the pid file created/managed by start-stop-daemon -DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid -DOCKER_LOGFILE=/var/log/$BASE.log -DOCKER_OPTS= -DOCKER_DESC="Docker" - -# Get lsb functions -. /lib/lsb/init-functions - -if [ -f /etc/default/$BASE ]; then - . /etc/default/$BASE -fi - -# Check docker is present -if [ ! -x $DOCKERD ]; then - log_failure_msg "$DOCKERD not present or not executable" - exit 1 -fi - -check_init() { - # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly) - if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then - log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1" - exit 1 - fi -} - -fail_unless_root() { - if [ "$(id -u)" != '0' ]; then - log_failure_msg "$DOCKER_DESC must be run as root" - exit 1 - fi -} - -cgroupfs_mount() { - # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount - if grep -v '^#' /etc/fstab | grep -q cgroup \ - || [ ! -e /proc/cgroups ] \ - || [ ! -d /sys/fs/cgroup ]; then - return - fi - if ! mountpoint -q /sys/fs/cgroup; then - mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - fi - ( - cd /sys/fs/cgroup - for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do - mkdir -p $sys - if ! mountpoint -q $sys; then - if ! mount -n -t cgroup -o $sys cgroup $sys; then - rmdir $sys || true - fi - fi - done - ) -} - -case "$1" in - start) - check_init - - fail_unless_root - - cgroupfs_mount - - touch "$DOCKER_LOGFILE" - chgrp docker "$DOCKER_LOGFILE" - - ulimit -n 1048576 - - # Having non-zero limits causes performance problems due to accounting overhead - # in the kernel. We recommend using cgroups to do container-local accounting. - if [ "$BASH" ]; then - ulimit -u unlimited - else - ulimit -p unlimited - fi - - log_begin_msg "Starting $DOCKER_DESC: $BASE" - start-stop-daemon --start --background \ - --no-close \ - --exec "$DOCKERD" \ - --pidfile "$DOCKER_SSD_PIDFILE" \ - --make-pidfile \ - -- \ - -p "$DOCKER_PIDFILE" \ - $DOCKER_OPTS \ - >> "$DOCKER_LOGFILE" 2>&1 - log_end_msg $? - ;; - - stop) - check_init - fail_unless_root - if [ -f "$DOCKER_SSD_PIDFILE" ]; then - log_begin_msg "Stopping $DOCKER_DESC: $BASE" - start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10 - log_end_msg $? - else - log_warning_msg "Docker already stopped - file $DOCKER_SSD_PIDFILE not found." - fi - ;; - - restart) - check_init - fail_unless_root - docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null` - [ -n "$docker_pid" ] \ - && ps -p $docker_pid > /dev/null 2>&1 \ - && $0 stop - $0 start - ;; - - force-reload) - check_init - fail_unless_root - $0 restart - ;; - - status) - check_init - status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKERD" "$DOCKER_DESC" - ;; - - *) - echo "Usage: service docker {start|stop|restart|status}" - exit 1 - ;; -esac diff --git a/deb/common/docker-ce.docker.upstart b/deb/common/docker-ce.docker.upstart deleted file mode 100644 index d58f7d6ac8..0000000000 --- a/deb/common/docker-ce.docker.upstart +++ /dev/null @@ -1,72 +0,0 @@ -description "Docker daemon" - -start on (filesystem and net-device-up IFACE!=lo) -stop on runlevel [!2345] - -limit nofile 524288 1048576 - -# Having non-zero limits causes performance problems due to accounting overhead -# in the kernel. We recommend using cgroups to do container-local accounting. -limit nproc unlimited unlimited - -respawn - -kill timeout 20 - -pre-start script - # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount - if grep -v '^#' /etc/fstab | grep -q cgroup \ - || [ ! -e /proc/cgroups ] \ - || [ ! -d /sys/fs/cgroup ]; then - exit 0 - fi - if ! mountpoint -q /sys/fs/cgroup; then - mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - fi - ( - cd /sys/fs/cgroup - for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do - mkdir -p $sys - if ! mountpoint -q $sys; then - if ! mount -n -t cgroup -o $sys cgroup $sys; then - rmdir $sys || true - fi - fi - done - ) -end script - -script - # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) - DOCKERD=/usr/bin/dockerd - DOCKER_OPTS= - if [ -f /etc/default/$UPSTART_JOB ]; then - . /etc/default/$UPSTART_JOB - fi - exec "$DOCKERD" $DOCKER_OPTS --raw-logs -end script - -# Don't emit "started" event until docker.sock is ready. -# See https://github.com/docker/docker/issues/6647 -post-start script - DOCKER_OPTS= - DOCKER_SOCKET= - if [ -f /etc/default/$UPSTART_JOB ]; then - . /etc/default/$UPSTART_JOB - fi - - if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then - DOCKER_SOCKET=/var/run/docker.sock - else - DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)\W*unix://\K(\S+)' | sed 1q) - fi - - if [ -n "$DOCKER_SOCKET" ]; then - while ! [ -e "$DOCKER_SOCKET" ]; do - initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1 - echo "Waiting for $DOCKER_SOCKET" - sleep 0.1 - done - echo "$DOCKER_SOCKET is up" - fi -end script diff --git a/deb/common/docker-ce.install b/deb/common/docker-ce.install deleted file mode 100644 index 1e23903064..0000000000 --- a/deb/common/docker-ce.install +++ /dev/null @@ -1,11 +0,0 @@ -#engine/contrib/syntax/vim/doc/* /usr/share/vim/vimfiles/doc/ -#engine/contrib/syntax/vim/ftdetect/* /usr/share/vim/vimfiles/ftdetect/ -#engine/contrib/syntax/vim/syntax/* /usr/share/vim/vimfiles/syntax/ -engine/contrib/check-config.sh usr/share/docker-ce/contrib/ -cli/contrib/completion/fish/docker.fish usr/share/fish/vendor_completions.d/ -cli/contrib/completion/zsh/_docker usr/share/zsh/vendor-completions/ -systemd/docker.service lib/systemd/system/ -systemd/docker.socket lib/systemd/system/ -engine/contrib/mk* usr/share/docker-ce/contrib/ -engine/contrib/nuke-graph-directory.sh usr/share/docker-ce/contrib/ -engine/contrib/syntax/nano/Dockerfile.nanorc usr/share/nano/ diff --git a/deb/common/docker-ce.postinst b/deb/common/docker-ce.postinst index eeef6ca801..f0cb34de8e 100644 --- a/deb/common/docker-ce.postinst +++ b/deb/common/docker-ce.postinst @@ -7,6 +7,10 @@ case "$1" in if ! getent group docker > /dev/null; then groupadd --system docker fi + # TODO Needs upgrade vs. install logic handling here + if ctr --namespace docker container info dockerd 2&>1 > /dev/null ; then + docker engine init + fi fi ;; abort-*) diff --git a/deb/common/docker-ce.udev b/deb/common/docker-ce.udev deleted file mode 100644 index f934c01757..0000000000 --- a/deb/common/docker-ce.udev +++ /dev/null @@ -1,3 +0,0 @@ -# hide docker's loopback devices from udisks, and thus from user desktops -SUBSYSTEM=="block", ENV{DM_NAME}=="docker-*", ENV{UDISKS_PRESENTATION_HIDE}="1", ENV{UDISKS_IGNORE}="1" -SUBSYSTEM=="block", DEVPATH=="/devices/virtual/block/loop*", ATTR{loop/backing_file}=="/var/lib/docker/*", ENV{UDISKS_PRESENTATION_HIDE}="1", ENV{UDISKS_IGNORE}="1" diff --git a/deb/common/docs b/deb/common/docs index 073f189abb..1e89a49202 100644 --- a/deb/common/docs +++ b/deb/common/docs @@ -1 +1 @@ -engine/README.md +cli/README.md diff --git a/deb/common/rules b/deb/common/rules index f75a8eafce..27e05dcee7 100644 --- a/deb/common/rules +++ b/deb/common/rules @@ -10,41 +10,21 @@ override_dh_gencontrol: dh_gencontrol override_dh_auto_build: - cd engine && ./hack/make.sh dynbinary cd /go/src/github.com/docker/cli && LDFLAGS='' make VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages override_dh_auto_test: - ./engine/bundles/dynbinary-daemon/dockerd -v + #./engine/bundles/dynbinary-daemon/dockerd -v override_dh_strip: # Go has lots of problems with stripping, so just don't override_dh_auto_install: - mkdir -p debian/docker-ce/usr/bin - cp -aTL cli/build/docker debian/docker-ce/usr/bin/docker - cp -aT "$$(readlink -f engine/bundles/dynbinary-daemon/dockerd)" debian/docker-ce/usr/bin/dockerd - cp -aT /usr/local/bin/docker-proxy debian/docker-ce/usr/bin/docker-proxy - cp -aT /usr/local/bin/docker-containerd debian/docker-ce/usr/bin/docker-containerd - cp -aT /usr/local/bin/docker-containerd-shim debian/docker-ce/usr/bin/docker-containerd-shim - cp -aT /usr/local/bin/docker-containerd-ctr debian/docker-ce/usr/bin/docker-containerd-ctr - cp -aT /usr/local/bin/docker-runc debian/docker-ce/usr/bin/docker-runc - cp -aT /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init - mkdir -p debian/docker-ce/usr/lib/docker - -override_dh_installinit: - # use "docker" as our service name, not "docker-ce" - dh_installinit --name=docker -ifeq (true, $(SYSTEMD_GT_227)) - $(warning "Setting TasksMax=infinity") - sed -i -- 's/#TasksMax=infinity/TasksMax=infinity/' debian/docker-ce/lib/systemd/system/docker.service -endif - -override_dh_installudev: - # match our existing priority - dh_installudev --priority=z80 + mkdir -p debian/docker-ce-cli/usr/bin + cp -aTL cli/build/docker debian/docker-ce-cli/usr/bin/docker override_dh_install: dh_install + # TODO Can we do this from within our container? dh_apparmor --profile-name=docker-ce -pdocker-ce override_dh_shlibdeps: