1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages docker)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (gnu packages)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system go)
30 #:use-module (guix build-system python)
31 #:use-module (guix utils)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages glib)
37 #:use-module (gnu packages golang)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages networking)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages python)
42 #:use-module (gnu packages python-web)
43 #:use-module (gnu packages python-xyz)
44 #:use-module (gnu packages version-control)
45 #:use-module (gnu packages virtualization))
47 (define %docker-version "18.09.5")
49 (define-public python-docker-py
51 (name "python-docker-py")
56 (uri (pypi-uri "docker-py" version))
59 "05f49f6hnl7npmi7kigg0ibqk8s3fhzx1ivvz1kqvlv4ay3paajc"))))
60 (build-system python-build-system)
61 ;; TODO: Tests require a running Docker daemon.
62 (arguments '(#:tests? #f))
64 `(("python-requests" ,python-requests)
65 ("python-six" ,python-six)
66 ("python-websocket-client" ,python-websocket-client)))
67 (home-page "https://github.com/docker/docker-py/")
68 (synopsis "Python client for Docker")
69 (description "Docker-Py is a Python client for the Docker container
71 (license license:asl2.0)))
73 (define-public python-dockerpty
75 (name "python-dockerpty")
80 (uri (pypi-uri "dockerpty" version))
83 "0za6rr349641wv76ww9l3zcic2xyxrirlxpnzl4296h897648455"))))
84 (build-system python-build-system)
86 `(("python-six" ,python-six)))
87 (home-page "https://github.com/d11wtq/dockerpty")
88 (synopsis "Python library to use the pseudo-TTY of a Docker container")
89 (description "Docker PTY provides the functionality needed to operate the
90 pseudo-terminal (PTY) allocated to a Docker container using the Python
92 (license license:asl2.0)))
94 (define-public docker-compose
96 (name "docker-compose")
101 (uri (pypi-uri "docker-compose" version))
104 "0ksg7hm2yvc977968dixxisrhcmvskzpcx3pz0v1kazrdqp7xakr"))))
105 (build-system python-build-system)
106 ;; TODO: Tests require running Docker daemon.
107 (arguments '(#:tests? #f))
109 `(("python-docker-py" ,python-docker-py)
110 ("python-dockerpty" ,python-dockerpty)
111 ("python-docopt" ,python-docopt)
112 ("python-jsonschema" ,python-jsonschema)
113 ("python-pyyaml" ,python-pyyaml)
114 ("python-requests" ,python-requests-2.7)
115 ("python-six" ,python-six)
116 ("python-texttable" ,python-texttable)
117 ("python-websocket-client" ,python-websocket-client)))
118 (home-page "https://www.docker.com/")
119 (synopsis "Multi-container orchestration for Docker")
120 (description "Docker Compose is a tool for defining and running
121 multi-container Docker applications. A Compose file is used to configure an
122 application’s services. Then, using a single command, the containers are
123 created and all the services are started as specified in the configuration.")
124 (license license:asl2.0)))
126 (define-public python-docker-pycreds
128 (name "python-docker-pycreds")
133 (uri (pypi-uri "docker-pycreds" version))
136 "1zxvam1q22qb0jf48553nnncnfrcp88ag4xa0qmq6vr0imn9a3lb"))))
137 (build-system python-build-system)
140 (modify-phases %standard-phases
141 (add-after 'unpack 'fix-versioning
143 (substitute* "test-requirements.txt"
144 (("3.0.2") ,(package-version python-pytest))
145 (("2.3.1") ,(package-version python-pytest-cov))
146 (("2.4.1") ,(package-version python-flake8)))
149 `(("python-flake8" ,python-flake8)
150 ("python-pytest" ,python-pytest)
151 ("python-pytest-cov" ,python-pytest-cov)))
153 `(("python-six" ,python-six)))
154 (home-page "https://github.com/shin-/dockerpy-creds")
156 "Python bindings for the Docker credentials store API")
158 "Docker-Pycreds contains the Python bindings for the docker credentials
159 store API. It allows programmers to interact with a Docker registry using
160 Python without keeping their credentials in a Docker configuration file.")
161 (license license:asl2.0)))
163 (define-public containerd
171 (url "https://github.com/containerd/containerd.git")
172 (commit (string-append "v" version))))
173 (file-name (git-file-name name version))
175 (base32 "0npbzixf3c0jvzm159vygvkydrr8h36c9sq50yv0mdinrys2bvg0"))))
176 (build-system go-build-system)
178 `(#:import-path "github.com/containerd/containerd"
180 (modify-phases %standard-phases
181 (add-before 'build 'chdir
183 (chdir "src/github.com/containerd/containerd")
185 (add-after 'chdir 'patch-paths
186 (lambda* (#:key inputs outputs #:allow-other-keys)
187 ;; TODO: Patch "socat", "unpigz".
188 (substitute* "./runtime/v1/linux/runtime.go"
189 (("defaultRuntime[ \t]*=.*")
190 (string-append "defaultRuntime = \""
191 (assoc-ref inputs "runc")
193 (("defaultShim[ \t]*=.*")
194 (string-append "defaultShim = \""
195 (assoc-ref outputs "out")
196 "/bin/containerd-shim\"\n")))
197 (substitute* "./vendor/github.com/containerd/go-runc/runc.go"
198 (("DefaultCommand[ \t]*=.*")
199 (string-append "DefaultCommand = \""
200 (assoc-ref inputs "runc")
202 (substitute* "vendor/github.com/containerd/continuity/testutil/loopback/loopback_linux.go"
203 (("exec\\.Command\\(\"losetup\"") ; )
204 (string-append "exec.Command(\""
205 (assoc-ref inputs "util-linux")
206 "/sbin/losetup\""))) ;)
209 (lambda* (#:key (make-flags '()) #:allow-other-keys)
210 (apply invoke "make" make-flags)))
212 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
213 (let* ((out (assoc-ref outputs "out")))
214 (apply invoke "make" (string-append "DESTDIR=" out) "install"
217 `(("btrfs-progs" ,btrfs-progs)
218 ("libseccomp" ,libseccomp)
220 ("util-linux" ,util-linux)))
223 ("pkg-config" ,pkg-config)))
224 (synopsis "Docker container runtime")
225 (description "This package provides the container daemon for Docker.
226 It includes image transfer and storage, container execution and supervision,
227 network attachments.")
228 (home-page "http://containerd.io/")
229 (license license:asl2.0)))
231 ;;; Private package that shouldn't be used directly; its purposes is to be
232 ;;; used as a template for the various packages it contains. It doesn't build
233 ;;; anyway, as it needs many dependencies that aren't being satisfied.
234 (define docker-libnetwork
235 ;; There are no recent release for libnetwork, so choose the last commit of
236 ;; the branch that Docker uses, as can be seen in the Docker source file
237 ;; 'hack/dockerfile/install/proxy.installer'.
238 (let ((commit "4725f2163fb214a6312f3beae5991f838ec36326")
242 (name "docker-libnetwork")
243 (version (git-version version "1" commit))
247 (url "https://github.com/docker/libnetwork.git")
249 (file-name (git-file-name name version))
252 "1zpnxki8qfzha6ljahpwd3vkzmjhsvkmf73w6crm4ilxxw5vnpfb"))
253 ;; Delete bundled ("vendored") free software source code.
254 (modules '((guix build utils)))
256 (delete-file-recursively "vendor")
258 (build-system go-build-system)
260 `(#:import-path "github.com/docker/libnetwork/"))
261 (home-page "https://github.com/docker/libnetwork/")
262 (synopsis "Networking for containers")
263 (description "Libnetwork provides a native Go implementation for
264 connecting containers. The goal of @code{libnetwork} is to deliver a robust
265 container network model that provides a consistent programming interface and
266 the required network abstractions for applications.")
267 (license license:asl2.0))))
269 (define-public docker-libnetwork-cmd-proxy
271 (inherit docker-libnetwork)
272 (name "docker-libnetwork-cmd-proxy")
274 `(#:import-path "github.com/docker/libnetwork/cmd/proxy"
275 #:unpack-path "github.com/docker/libnetwork"
276 #:install-source? #f))
278 `(("go-sctp" ,go-sctp)
280 ("logrus" ,go-github-com-sirupsen-logrus)
281 ("go-netlink" ,go-netlink)
282 ("go-netns" ,go-netns)
283 ("go-golang-org-x-crypto-ssh-terminal"
284 ,go-golang-org-x-crypto-ssh-terminal)
285 ("go-golang-org-x-sys-unix" ,go-golang-org-x-sys-unix)))
286 (synopsis "Docker user-space proxy")
287 (description "A proxy running in the user space. It is used by the
288 built-in registry server of Docker.")
289 (license license:asl2.0)))
291 ;; TODO: Patch out modprobes for ip_vs, nf_conntrack,
292 ;; brige, nf_conntrack_netlink, aufs.
293 (define-public docker
296 (version %docker-version)
301 (url "https://github.com/docker/engine.git")
302 (commit (string-append "v" version))))
303 (file-name (git-file-name name version))
305 (base32 "0cirpd9l2qazp2jyanwzvrkx2m98nksjdvn43ff38p89w6133ipb"))
307 (search-patches "docker-engine-test-noinstall.patch"
308 "docker-fix-tests.patch"
309 "docker-use-fewer-modprobes.patch"))))
310 (build-system gnu-build-system)
313 ((guix build gnu-build-system)
314 ((guix build go-build-system) #:prefix go:)
318 (,@%gnu-build-system-modules
320 (guix build go-build-system))
322 (modify-phases %standard-phases
323 (add-after 'unpack 'patch-paths
324 (lambda* (#:key inputs #:allow-other-keys)
325 (substitute* "builder/builder-next/executor_unix.go"
326 (("CommandCandidates:.*runc.*")
327 (string-append "CommandCandidates: []string{\""
328 (assoc-ref inputs "runc")
329 "/sbin/runc\"},\n")))
330 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
331 (("DefaultCommand = .*")
332 (string-append "DefaultCommand = \""
333 (assoc-ref inputs "runc")
335 (substitute* "vendor/github.com/containerd/containerd/runtime/v1/linux/runtime.go"
336 (("defaultRuntime[ \t]*=.*")
337 (string-append "defaultRuntime = \""
338 (assoc-ref inputs "runc")
340 (("defaultShim[ \t]*=.*")
341 (string-append "defaultShim = \""
342 (assoc-ref inputs "containerd")
343 "/bin/containerd-shim\"\n")))
344 (substitute* "daemon/daemon_unix.go"
345 (("DefaultShimBinary = .*")
346 (string-append "DefaultShimBinary = \""
347 (assoc-ref inputs "containerd")
348 "/bin/containerd-shim\"\n"))
349 (("DefaultRuntimeBinary = .*")
350 (string-append "DefaultRuntimeBinary = \""
351 (assoc-ref inputs "runc")
353 (("DefaultRuntimeName = .*")
354 (string-append "DefaultRuntimeName = \""
355 (assoc-ref inputs "runc")
357 (substitute* "daemon/config/config.go"
358 (("StockRuntimeName = .*")
359 (string-append "StockRuntimeName = \""
360 (assoc-ref inputs "runc")
362 (substitute* "vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go"
363 (("var defaultCommandCandidates = .*")
364 (string-append "var defaultCommandCandidates = []string{\""
365 (assoc-ref inputs "runc") "/sbin/runc\"}")))
366 (substitute* "vendor/github.com/docker/libnetwork/portmapper/proxy.go"
367 (("var userlandProxyCommandName = .*")
368 (string-append "var userlandProxyCommandName = \""
369 (assoc-ref inputs "docker-proxy")
371 (substitute* "pkg/archive/archive.go"
373 (string-append "string{\"" (assoc-ref inputs "xz") "/bin/xz")))
374 (let ((source-files (filter (lambda (name)
375 (not (string-contains name "test")))
376 (find-files "." "\\.go$"))))
377 (let-syntax ((substitute-LookPath*
379 ((_ (source-text package relative-path) ...)
380 (substitute* source-files
381 (((string-append "\\<exec\\.LookPath\\(\""
385 (assoc-ref inputs package)
387 "\", error(nil)")) ...))))
390 ((_ (source-text package relative-path) ...)
391 (substitute* source-files
392 (((string-append "\\<(re)?exec\\.Command\\(\""
395 (string-append (if re? re? "")
397 (assoc-ref inputs package)
400 (substitute-LookPath*
401 ("ps" "procps" "bin/ps")
402 ("mkfs.xfs" "xfsprogs" "bin/mkfs.xfs")
403 ("lvmdiskscan" "lvm2" "sbin/lvmdiskscan")
404 ("pvdisplay" "lvm2" "sbin/pvdisplay")
405 ("blkid" "util-linux" "sbin/blkid")
406 ("unpigz" "pigz" "bin/unpigz")
407 ("iptables" "iptables" "sbin/iptables")
408 ("iptables-legacy" "iptables" "sbin/iptables")
409 ("ip" "iproute2" "sbin/ip"))
412 ("modprobe" "kmod" "bin/modprobe")
413 ("pvcreate" "lvm2" "sbin/pvcreate")
414 ("vgcreate" "lvm2" "sbin/vgcreate")
415 ("lvcreate" "lvm2" "sbin/lvcreate")
416 ("lvconvert" "lvm2" "sbin/lvconvert")
417 ("lvchange" "lvm2" "sbin/lvchange")
418 ("mkfs.xfs" "xfsprogs" "sbin/mkfs.xfs")
419 ("xfs_growfs" "xfsprogs" "sbin/xfs_growfs")
420 ("mkfs.ext4" "e2fsprogs" "sbin/mkfs.ext4")
421 ("tune2fs" "e2fsprogs" "sbin/tune2fs")
422 ("blkid" "util-linux" "sbin/blkid")
423 ("resize2fs" "e2fsprogs" "sbin/resize2fs")
424 ("ps" "procps" "bin/ps")
425 ("losetup" "util-linux" "sbin/losetup")
426 ("uname" "coreutils" "bin/uname")
427 ("dbus-launch" "dbus" "bin/dbus-launch")
428 ("git" "git" "bin/git")))
429 ;; docker-mountfrom ??
432 ;; docker-applyLayer ??
437 ;; Make compilation fail when, in future versions, Docker
438 ;; invokes other programs we don't know about and thus don't
440 (substitute* source-files
441 ;; Search for Java in PATH.
442 (("\\<exec\\.Command\\(\"java\"")
443 "xxec.Command(\"java\"")
444 ;; Search for AUFS in PATH (mainline Linux doesn't support it).
445 (("\\<exec\\.Command\\(\"auplink\"")
446 "xxec.Command(\"auplink\"")
447 ;; Fail on other unsubstituted commands.
448 (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
450 (string-append "exec.Guix_doesnt_want_Command(\""
452 (("\\<xxec\\.Command")
454 ;; Search for ZFS in PATH.
455 (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
456 ;; Fail on other unsubstituted LookPaths.
457 (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"")
458 (("\\<LooxPath") "LookPath")))
460 (add-after 'patch-paths 'delete-failing-tests
462 ;; Needs internet access.
463 (delete-file "builder/remotecontext/git/gitutils_test.go")
464 ;; Permission denied.
465 (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
466 ;; Operation not permitted (idtools.MkdirAllAndChown).
467 (delete-file "daemon/graphdriver/vfs/vfs_test.go")
468 ;; Timeouts after 5 min.
469 (delete-file "plugin/manager_linux_test.go")
470 ;; Operation not permitted.
471 (delete-file "daemon/graphdriver/btrfs/btrfs_test.go")
472 (delete-file "daemon/graphdriver/overlay/overlay_test.go")
473 (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
477 (setenv "DOCKER_GITCOMMIT" (string-append "v" ,%docker-version))
478 ;; Automatically use bundled dependencies.
479 ;; TODO: Unbundle - see file "vendor.conf".
480 (setenv "AUTO_GOPATH" "1")
481 ;; Respectively, strip the symbol table and debug
482 ;; information, and the DWARF symbol table.
483 (setenv "LDFLAGS" "-s -w")
485 (setenv "GOCACHE" "/tmp")
487 (add-before 'build 'setup-go-environment
488 (assoc-ref go:%standard-phases 'setup-go-environment))
491 ;; Our LD doesn't like the statically linked relocatable things
492 ;; that go produces, so install the dynamic version of
494 (invoke "hack/make.sh" "dynbinary")))
497 ;; The build process generated a file because the environment
498 ;; variable "AUTO_GOPATH" was set. Use it.
499 (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
500 ;; ".gopath/src/github.com/docker/docker" is a link to the current
501 ;; directory and chdir would canonicalize to that.
502 ;; But go needs to have the uncanonicalized directory name, so
504 (setenv "PWD" (string-append (getcwd)
505 "/.gopath/src/github.com/docker/docker"))
506 (with-directory-excursion ".gopath/src/github.com/docker/docker"
507 (invoke "hack/test/unit"))
511 (lambda* (#:key outputs #:allow-other-keys)
512 (let* ((out (assoc-ref outputs "out"))
513 (out-bin (string-append out "/bin")))
514 (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
515 (install-file "bundles/dynbinary-daemon/dockerd-dev" out-bin)
518 `(("btrfs-progs" ,btrfs-progs)
519 ("containerd" ,containerd) ; for containerd-shim
520 ("coreutils" ,coreutils)
522 ("docker-proxy" ,docker-libnetwork-cmd-proxy)
523 ("e2fsprogs" ,e2fsprogs)
525 ("iproute2" ,iproute)
526 ("iptables" ,iptables)
528 ("libseccomp" ,libseccomp)
532 ("util-linux" ,util-linux)
534 ("xfsprogs" ,xfsprogs)
537 `(("eudev" ,eudev) ; TODO: Should be propagated by lvm2 (.pc -> .pc)
539 ("pkg-config" ,pkg-config)))
540 (synopsis "Docker container component library, and daemon")
541 (description "This package provides a framework to assemble specialized
542 container systems. It includes components for orchestration, image
543 management, secret management, configuration management, networking,
545 (home-page "https://mobyproject.org/")
546 (license license:asl2.0)))
548 (define-public docker-cli
551 (version %docker-version)
556 (url "https://github.com/docker/cli.git")
557 (commit (string-append "v" version))))
558 (file-name (git-file-name name version))
560 (base32 "0mxxjzkwdny8p2dmyjich7x1gn7hdlfppzjy2skk2k5bwv7nxpmi"))))
561 (build-system go-build-system)
563 `(#:import-path "github.com/docker/cli"
564 ;; TODO: Tests require a running Docker daemon.
567 (modify-phases %standard-phases
568 (add-before 'build 'setup-environment-2
570 ;; Respectively, strip the symbol table and debug
571 ;; information, and the DWARF symbol table.
572 (setenv "LDFLAGS" "-s -w")
574 ;; Make build reproducible.
575 (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
576 (symlink "src/github.com/docker/cli/scripts" "./scripts")
577 (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")
581 (invoke "./scripts/build/dynbinary")))
583 (lambda* (#:key make-flags tests? #:allow-other-keys)
584 (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
586 ;; Use the newly-built docker client for the tests.
587 (with-directory-excursion "src/github.com/docker/cli"
588 ;; TODO: Run test-e2e as well?
589 (apply invoke "make" "-f" "docker.Makefile" "test-unit"
590 (or make-flags '())))
593 (lambda* (#:key outputs #:allow-other-keys)
594 (let* ((out (assoc-ref outputs "out"))
595 (out-bin (string-append out "/bin")))
597 (install-file "docker" out-bin)
602 ("pkg-config" ,pkg-config)))
603 (synopsis "Command line interface to Docker")
604 (description "This package provides a command line interface to Docker.")
605 (home-page "https://www.docker.com/")
606 (license license:asl2.0)))
615 (url "https://github.com/savoirfairelinux/cqfd.git")
616 (commit (string-append "v" version))))
617 (file-name (git-file-name name version))
620 "1xhydz01f2rrnw7rmnaxh3f3q1ariq7j2ig0i0w1p3wn10l3q0nv"))))
621 (build-system gnu-build-system)
623 ;; The test suite requires a docker daemon and connectivity.
626 (modify-phases %standard-phases
630 (lambda* (#:key outputs #:allow-other-keys)
631 (let ((out (assoc-ref outputs "out")))
632 ;; Fix the directory of the bash completion.
633 (substitute* "Makefile"
634 (("completionsdir=.*$")
635 (string-append "completionsdir=" out
636 "/etc/bash_completion.d; \\\n")))
637 (invoke "make" "install"
638 (string-append "PREFIX=" out))))))))
639 (home-page "https://github.com/savoirfairelinux/cqfd")
640 (synopsis "Convenience wrapper for Docker")
641 (description "cqfd is a Bash script that provides a quick and convenient
642 way to run commands in the current directory, but within a Docker container
643 defined in a per-project configuration file.")
644 (license license:gpl3+)))