Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jul 2015 15:37:34 +0000 (UTC)
From:      Kris Moore <kmoore@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r391421 - in head/sysutils: . docker docker/files
Message-ID:  <201507061537.t66FbYeo022971@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmoore
Date: Mon Jul  6 15:37:33 2015
New Revision: 391421
URL: https://svnweb.freebsd.org/changeset/ports/391421

Log:
  FreeBSD port of Docker
  
  WWW: https://github.com/kvasdopil/docker
  
  NOTE:
  
  This is a very early port of docker!
  
  Please refer to the pkg-message and
  https://github.com/kvasdopil/docker/blob/freebsd-compat/FREEBSD-PORTING.md
  for details on usage and functionality.

Added:
  head/sysutils/docker/
  head/sysutils/docker/Makefile   (contents, props changed)
  head/sysutils/docker/distinfo   (contents, props changed)
  head/sysutils/docker/files/
  head/sysutils/docker/files/docker.in   (contents, props changed)
  head/sysutils/docker/pkg-descr   (contents, props changed)
  head/sysutils/docker/pkg-message   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Mon Jul  6 15:16:25 2015	(r391420)
+++ head/sysutils/Makefile	Mon Jul  6 15:37:33 2015	(r391421)
@@ -201,6 +201,7 @@
     SUBDIR += djmount
     SUBDIR += dmg2img
     SUBDIR += dmidecode
+    SUBDIR += docker
     SUBDIR += doinkd
     SUBDIR += dolly
     SUBDIR += downtime

Added: head/sysutils/docker/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/docker/Makefile	Mon Jul  6 15:37:33 2015	(r391421)
@@ -0,0 +1,36 @@
+# Created by: kmoore@FreeBSD.org
+# $FreeBSD$
+
+PORTNAME=	docker
+PORTVERSION=	06252015
+CATEGORIES=	sysutils
+
+MAINTAINER=	kmoore@FreeBSD.org
+COMMENT=	Docker containment system
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	${LOCALBASE}/bin/go:${PORTSDIR}/lang/go \
+		${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash \
+		${LOCALBASE}/bin/git:${PORTSDIR}/devel/git \
+		sqlite3:${PORTSDIR}/databases/sqlite3
+RUN_DEPENDS=	${LOCALBASE}/bin/go:${PORTSDIR}/lang/go \
+		${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash \
+		sqlite3:${PORTSDIR}/databases/sqlite3
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	kvasdopil
+GH_TAGNAME=	582db78
+
+PLIST_FILES=	bin/docker
+USE_RC_SUBR=	docker
+
+do-build:
+	@cd ${WRKSRC} && export AUTO_GOPATH=1 && export DOCKER_GITCOMMIT=${GH_TAGNAME} && ./hack/make.sh binary
+
+do-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/bin
+	${INSTALL} ${WRKSRC}/bundles/latest/binary/docker ${STAGEDIR}${PREFIX}/bin/
+
+.include <bsd.port.mk>

Added: head/sysutils/docker/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/docker/distinfo	Mon Jul  6 15:37:33 2015	(r391421)
@@ -0,0 +1,2 @@
+SHA256 (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = a750d344af4af3d30b1a3373f382ab597a2a7aa4a0bb5c22d650d0c5cc9ac506
+SIZE (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = 7292884

Added: head/sysutils/docker/files/docker.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/docker/files/docker.in	Mon Jul  6 15:37:33 2015	(r391421)
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+# PROVIDE: docker
+# REQUIRE: DAEMON
+# KEYWORD: nojail shutdown
+
+. /etc/rc.subr
+
+name="docker"
+rcvar="docker_enable"
+
+stop_cmd="docker_stop"
+start_cmd="docker_start"
+command="%%PREFIX%%/bin/docker"
+
+load_rc_config $name
+
+: ${docker_enable=NO}
+: ${docker_dir=/usr/docker}
+: ${docker_nat_pf=YES}
+: ${docker_nat_iface=NONE}
+
+docker_start()
+{
+	if [ ! -d "${docker_dir}" ] ; then
+		echo "Missing ${docker_dir}! Please create / mount a ZFS dataset at this location."
+		exit 1
+	fi
+
+	if [ -e "/var/run/docker.pid" ] ; then
+		pgrep -F /var/run/docker.pid 2>/dev/null >/dev/null
+		if [ $? -eq 0 ] ; then
+			echo "Docker already running? /var/run/docker.pid"
+			exit 1
+		fi
+	fi
+
+	echo "Starting docker..."
+	daemon -p /var/run/docker.pid ${command} -d -e jail -s zfs -g ${docker_dir} -D >/var/log/docker.log 2>/var/log/docker.log
+
+	# Check for linux 64bit support and enable
+	kldstat | grep -q 'linux64'
+	if [ $? -ne 0 -a -e "/boot/kernel/linux64.ko" ] ; then
+		kldload linux64
+	fi
+
+	# Check for NAT support via PF
+	# This is an ugly experimental hack for now, eventually will go away
+	if [ "${docker_nat_pf}" != "YES" ] ; then return ; fi
+
+	# Load PF if not already
+	kldstat | grep -q 'pf.ko'
+	if [ $? -ne 0 -a -e "/boot/kernel/pf.ko" ] ; then
+		kldload pf
+	fi
+
+	# Check if PF rules already loaded
+	/sbin/pfctl -s nat 2>/dev/null | grep -q 172.17
+	if [ $? -eq 0 ] ; then return ; fi
+
+	if [ "${docker_nat_iface}" != "NONE" ] ; then
+		iface="${docker_nat_iface}"
+	else
+		iface=`/usr/bin/netstat -f inet -nrW | grep '^default' | awk '{ print $6 }'`
+	fi
+	echo "nat on ${iface} from 172.17.0.0/16 to any -> (${iface})" > /tmp/pf-nat-docker.$$
+	/sbin/pfctl -f /tmp/pf-nat-docker.$$ 2>/dev/null
+	/sbin/pfctl -e 2>/dev/null
+	rm /tmp/pf-nat-docker.$$
+
+}
+
+docker_stop()
+{
+	if [ -e "/var/run/docker.pid" ] ; then
+		echo "Stopping docker..."
+		pkill -F /var/run/docker.pid
+	fi
+}
+
+run_rc_command "$1"
+

Added: head/sysutils/docker/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/docker/pkg-descr	Mon Jul  6 15:37:33 2015	(r391421)
@@ -0,0 +1,3 @@
+FreeBSD port of Docker
+
+WWW: https://github.com/kvasdopil/docker

Added: head/sysutils/docker/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/docker/pkg-message	Mon Jul  6 15:37:33 2015	(r391421)
@@ -0,0 +1,21 @@
+
+Docker requires a bit of setup before usage. 
+
+You will need to create a ZFS dataset on /usr/docker
+
+# zfs create -o mountpoint=/usr/docker <zroot>/docker 
+
+And lastly enable the docker daemon
+# sysrc -f /etc/rc.conf docker_enable="YES"
+# service docker start
+
+(WARNING)
+
+Starting the docker service will also add the following PF rule:
+
+nat on ${iface} from 172.17.0.0/16 to any -> (${iface})
+
+Where $iface is the default NIC on the system, or the value
+of $docker_nat_iface. This is for network connectivity to docker
+containers in this early port. This should not be needed in future
+versions of docker. 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507061537.t66FbYeo022971>