aboutsummaryrefslogtreecommitdiff
path: root/sysutils/docker
diff options
context:
space:
mode:
authorKris Moore <kmoore@FreeBSD.org>2015-07-06 15:37:33 +0000
committerKris Moore <kmoore@FreeBSD.org>2015-07-06 15:37:33 +0000
commitb9d84bad7cdbdbfa6daca58b3524760acd747063 (patch)
tree8f39a4bf98da6fb45aabe2a86d9d5c74504f2da1 /sysutils/docker
parentdd5c9a9c59935bff0aff7c5948c4b77e5799d403 (diff)
downloadports-b9d84bad7cdbdbfa6daca58b3524760acd747063.tar.gz
ports-b9d84bad7cdbdbfa6daca58b3524760acd747063.zip
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.
Notes
Notes: svn path=/head/; revision=391421
Diffstat (limited to 'sysutils/docker')
-rw-r--r--sysutils/docker/Makefile36
-rw-r--r--sysutils/docker/distinfo2
-rw-r--r--sysutils/docker/files/docker.in82
-rw-r--r--sysutils/docker/pkg-descr3
-rw-r--r--sysutils/docker/pkg-message21
5 files changed, 144 insertions, 0 deletions
diff --git a/sysutils/docker/Makefile b/sysutils/docker/Makefile
new file mode 100644
index 000000000000..7fc20afa2e21
--- /dev/null
+++ b/sysutils/docker/Makefile
@@ -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>
diff --git a/sysutils/docker/distinfo b/sysutils/docker/distinfo
new file mode 100644
index 000000000000..9e57abf4a6c3
--- /dev/null
+++ b/sysutils/docker/distinfo
@@ -0,0 +1,2 @@
+SHA256 (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = a750d344af4af3d30b1a3373f382ab597a2a7aa4a0bb5c22d650d0c5cc9ac506
+SIZE (kvasdopil-docker-06252015-582db78_GH0.tar.gz) = 7292884
diff --git a/sysutils/docker/files/docker.in b/sysutils/docker/files/docker.in
new file mode 100644
index 000000000000..394e5b574de5
--- /dev/null
+++ b/sysutils/docker/files/docker.in
@@ -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"
+
diff --git a/sysutils/docker/pkg-descr b/sysutils/docker/pkg-descr
new file mode 100644
index 000000000000..18333dc4dcfe
--- /dev/null
+++ b/sysutils/docker/pkg-descr
@@ -0,0 +1,3 @@
+FreeBSD port of Docker
+
+WWW: https://github.com/kvasdopil/docker
diff --git a/sysutils/docker/pkg-message b/sysutils/docker/pkg-message
new file mode 100644
index 000000000000..f01d94f6fa82
--- /dev/null
+++ b/sysutils/docker/pkg-message
@@ -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.