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 pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages python-web)
42 #:use-module (gnu packages python-xyz)
43 #:use-module (gnu packages version-control)
44 #:use-module (gnu packages virtualization))
46 (define %docker-version "18.09.0")
48 (define-public python-docker-py
50 (name "python-docker-py")
55 (uri (pypi-uri "docker-py" version))
58 "05f49f6hnl7npmi7kigg0ibqk8s3fhzx1ivvz1kqvlv4ay3paajc"))))
59 (build-system python-build-system)
60 ;; TODO: Tests require a running Docker daemon.
61 (arguments '(#:tests? #f))
63 `(("python-requests" ,python-requests)
64 ("python-six" ,python-six)
65 ("python-websocket-client" ,python-websocket-client)))
66 (home-page "https://github.com/docker/docker-py/")
67 (synopsis "Python client for Docker")
68 (description "Docker-Py is a Python client for the Docker container
70 (license license:asl2.0)))
72 (define-public python-dockerpty
74 (name "python-dockerpty")
79 (uri (pypi-uri "dockerpty" version))
82 "0za6rr349641wv76ww9l3zcic2xyxrirlxpnzl4296h897648455"))))
83 (build-system python-build-system)
85 `(("python-six" ,python-six)))
86 (home-page "https://github.com/d11wtq/dockerpty")
87 (synopsis "Python library to use the pseudo-TTY of a Docker container")
88 (description "Docker PTY provides the functionality needed to operate the
89 pseudo-terminal (PTY) allocated to a Docker container using the Python
91 (license license:asl2.0)))
93 (define-public docker-compose
95 (name "docker-compose")
100 (uri (pypi-uri "docker-compose" version))
103 "0ksg7hm2yvc977968dixxisrhcmvskzpcx3pz0v1kazrdqp7xakr"))))
104 (build-system python-build-system)
105 ;; TODO: Tests require running Docker daemon.
106 (arguments '(#:tests? #f))
108 `(("python-docker-py" ,python-docker-py)
109 ("python-dockerpty" ,python-dockerpty)
110 ("python-docopt" ,python-docopt)
111 ("python-jsonschema" ,python-jsonschema)
112 ("python-pyyaml" ,python-pyyaml)
113 ("python-requests" ,python-requests-2.7)
114 ("python-six" ,python-six)
115 ("python-texttable" ,python-texttable)
116 ("python-websocket-client" ,python-websocket-client)))
117 (home-page "https://www.docker.com/")
118 (synopsis "Multi-container orchestration for Docker")
119 (description "Docker Compose is a tool for defining and running
120 multi-container Docker applications. A Compose file is used to configure an
121 application’s services. Then, using a single command, the containers are
122 created and all the services are started as specified in the configuration.")
123 (license license:asl2.0)))
125 (define-public python-docker-pycreds
127 (name "python-docker-pycreds")
132 (uri (pypi-uri "docker-pycreds" version))
135 "1zxvam1q22qb0jf48553nnncnfrcp88ag4xa0qmq6vr0imn9a3lb"))))
136 (build-system python-build-system)
139 (modify-phases %standard-phases
140 (add-after 'unpack 'fix-versioning
142 (substitute* "test-requirements.txt"
143 (("3.0.2") ,(package-version python-pytest))
144 (("2.3.1") ,(package-version python-pytest-cov))
145 (("2.4.1") ,(package-version python-flake8)))
148 `(("python-flake8" ,python-flake8)
149 ("python-pytest" ,python-pytest)
150 ("python-pytest-cov" ,python-pytest-cov)))
152 `(("python-six" ,python-six)))
153 (home-page "https://github.com/shin-/dockerpy-creds")
155 "Python bindings for the Docker credentials store API")
157 "Docker-Pycreds contains the Python bindings for the docker credentials
158 store API. It allows programmers to interact with a Docker registry using
159 Python without keeping their credentials in a Docker configuration file.")
160 (license license:asl2.0)))
162 (define-public containerd
170 (url "https://github.com/containerd/containerd.git")
171 (commit (string-append "v" version))))
172 (file-name (git-file-name name version))
175 "065snv0s3v3z0ghadlii4w78qnhchcbx2kfdrvm8fk8gb4pkx1ya"))))
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 (define-public docker
234 (version %docker-version)
239 (url "https://github.com/docker/engine.git")
240 (commit (string-append "v" version))))
241 (file-name (git-file-name name version))
244 "1liqbx58grqih6m8hz9y20y5waflv19pv15l3wl64skap2bsn21c"))
246 (search-patches "docker-engine-test-noinstall.patch"
247 "docker-fix-tests.patch"))))
248 (build-system gnu-build-system)
251 ((guix build gnu-build-system)
252 ((guix build go-build-system) #:prefix go:)
255 (,@%gnu-build-system-modules
256 (guix build go-build-system))
258 (modify-phases %standard-phases
259 (add-after 'unpack 'patch-paths
260 (lambda* (#:key inputs #:allow-other-keys)
261 (substitute* "builder/builder-next/executor_unix.go"
262 (("CommandCandidates:.*runc.*")
263 (string-append "CommandCandidates: []string{\""
264 (assoc-ref inputs "runc")
265 "/sbin/runc\"},\n")))
266 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
267 (("DefaultCommand = .*")
268 (string-append "DefaultCommand = \""
269 (assoc-ref inputs "runc")
271 (substitute* "vendor/github.com/containerd/containerd/runtime/v1/linux/runtime.go"
272 (("defaultRuntime[ \t]*=.*")
273 (string-append "defaultRuntime = \""
274 (assoc-ref inputs "runc")
276 (("defaultShim[ \t]*=.*")
277 (string-append "defaultShim = \""
278 (assoc-ref inputs "containerd")
279 "/bin/containerd-shim\"\n")))
280 (substitute* "daemon/daemon_unix.go"
281 (("DefaultShimBinary = .*")
282 (string-append "DefaultShimBinary = \""
283 (assoc-ref inputs "containerd")
284 "/bin/containerd-shim\"\n"))
285 (("DefaultRuntimeBinary = .*")
286 (string-append "DefaultRuntimeBinary = \""
287 (assoc-ref inputs "runc")
289 (("DefaultRuntimeName = .*")
290 (string-append "DefaultRuntimeName = \""
291 (assoc-ref inputs "runc")
293 (substitute* "daemon/config/config.go"
294 (("StockRuntimeName = .*")
295 (string-append "StockRuntimeName = \""
296 (assoc-ref inputs "runc")
298 (substitute* "vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go"
299 (("var defaultCommandCandidates = .*")
300 (string-append "var defaultCommandCandidates = []string{\""
301 (assoc-ref inputs "runc") "/sbin/runc\"}")))
302 (let ((source-files (filter (lambda (name)
303 (not (string-contains name "test")))
304 (find-files "." "\\.go$"))))
305 (let-syntax ((substitute-LookPath
308 ((substitute-LookPath source-text package
310 #`(substitute* source-files
311 ((#,(string-append "exec\\.LookPath\\(\""
316 (assoc-ref inputs package)
318 "\", error(nil)")))))))
322 ((substitute-LookPath source-text package
324 #`(substitute* source-files
325 ((#,(string-append "exec\\.Command\\(\""
329 (string-append "exec.Command(\""
330 (assoc-ref inputs package)
333 (substitute-LookPath "ps" "procps" "/bin/ps")
334 (substitute-LookPath "mkfs.xfs" "xfsprogs" "/bin/mkfs.xfs")
335 (substitute-LookPath "lvmdiskscan" "lvm2" "/sbin/lvmdiskscan")
336 (substitute-LookPath "pvdisplay" "lvm2" "/sbin/pvdisplay")
337 (substitute-LookPath "blkid" "util-linux" "/sbin/blkid")
338 (substitute-LookPath "unpigz" "pigz" "/bin/unpigz")
339 (substitute-LookPath "iptables" "iptables" "/sbin/iptables")
340 (substitute-LookPath "ip" "iproute2" "/sbin/ip")
341 (substitute-Command "modprobe" "kmod" "/bin/modprobe")
342 (substitute-Command "pvcreate" "lvm2" "/sbin/pvcreate")
343 (substitute-Command "vgcreate" "lvm2" "/sbin/vgcreate")
344 (substitute-Command "lvcreate" "lvm2" "/sbin/lvcreate")
345 (substitute-Command "lvconvert" "lvm2" "/sbin/lvconvert")
346 (substitute-Command "lvchange" "lvm2" "/sbin/lvchange")
347 (substitute-Command "mkfs.xfs" "xfsprogs" "/sbin/mkfs.xfs")
348 (substitute-Command "xfs_growfs" "xfsprogs" "/sbin/xfs_growfs")
349 (substitute-Command "mkfs.ext4" "e2fsprogs" "/sbin/mkfs.ext4")
350 (substitute-Command "tune2fs" "e2fsprogs" "/sbin/tune2fs")
351 (substitute-Command "blkid" "util-linux" "/sbin/blkid")
352 (substitute-Command "resize2fs" "e2fsprogs" "/sbin/resize2fs")
353 ; docker-mountfrom ??
356 ; docker-applyLayer ??
360 (substitute-Command "ps" "procps" "/bin/ps")
361 (substitute-Command "losetup" "util-linux" "/sbin/losetup")
362 (substitute-Command "uname" "coreutils" "/bin/uname")
363 (substitute-Command "dbus-launch" "dbus" "/bin/dbus-launch")
364 (substitute-Command "git" "git" "/bin/git"))
365 ;; Make compilation fail when, in future versions, Docker
366 ;; invokes other programs we don't know about and thus don't
368 (substitute* source-files
369 ;; Search for Java in PATH.
370 (("\\<exec\\.Command\\(\"java\"") ; )
371 "xxec.Command(\"java\"") ; )
372 ;; Search for AUFS in PATH (mainline Linux doesn't support it).
373 (("\\<exec\\.Command\\(\"auplink\"") ; )
374 "xxec.Command(\"auplink\"") ; )
375 ;; Fail on other unsubstituted commands.
376 (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
378 (string-append "exec.Guix_doesnt_want_Command(\""
380 (("\\<xxec\\.Command")
382 ;; Search for ZFS in PATH.
383 (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
384 ;; Fail on other unsubstituted LookPaths.
385 (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"") ; ))
386 (("\\<LooxPath") "LookPath")))
388 (add-after 'patch-paths 'delete-failing-tests
390 ;; Needs internet access.
391 (delete-file "builder/remotecontext/git/gitutils_test.go")
392 ;; Permission denied.
393 (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
394 ;; Operation not permitted (idtools.MkdirAllAndChown).
395 (delete-file "daemon/graphdriver/vfs/vfs_test.go")
396 ;; Timeouts after 5 min.
397 (delete-file "plugin/manager_linux_test.go")
398 ;; Operation not permitted.
399 (delete-file "daemon/graphdriver/overlay/overlay_test.go")
400 (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
404 (setenv "DOCKER_GITCOMMIT" (string-append "v" ,%docker-version))
405 ;; Automatically use bundled dependencies.
406 ;; TODO: Unbundle - see file "vendor.conf".
407 (setenv "AUTO_GOPATH" "1")
408 ;; Respectively, strip the symbol table and debug
409 ;; information, and the DWARF symbol table.
410 (setenv "LDFLAGS" "-s -w")
412 (setenv "GOCACHE" "/tmp")
414 (add-before 'build 'setup-environment
415 (assoc-ref go:%standard-phases 'setup-environment))
418 ;; Our LD doesn't like the statically linked relocatable things
419 ;; that go produces, so install the dynamic version of
421 (invoke "hack/make.sh" "dynbinary")))
424 ;; The build process generated a file because the environment
425 ;; variable "AUTO_GOPATH" was set. Use it.
426 (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
427 ;; ".gopath/src/github.com/docker/docker" is a link to the current
428 ;; directory and chdir would canonicalize to that.
429 ;; But go needs to have the uncanonicalized directory name, so
431 (setenv "PWD" (string-append (getcwd)
432 "/.gopath/src/github.com/docker/docker"))
433 (with-directory-excursion ".gopath/src/github.com/docker/docker"
434 (invoke "hack/test/unit"))
438 (lambda* (#:key outputs #:allow-other-keys)
439 (let* ((out (assoc-ref outputs "out"))
440 (out-bin (string-append out "/bin")))
441 (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
442 (install-file "bundles/dynbinary-daemon/dockerd-dev" out-bin)
445 `(("btrfs-progs" ,btrfs-progs)
446 ("containerd" ,containerd) ; for containerd-shim
447 ("coreutils" ,coreutils)
449 ("e2fsprogs" ,e2fsprogs)
451 ("iproute2" ,iproute)
452 ("iptables" ,iptables)
454 ("libseccomp" ,libseccomp)
458 ("util-linux" ,util-linux)
460 ("xfsprogs" ,xfsprogs)))
462 `(("eudev" ,eudev) ; TODO: Should be propagated by lvm2 (.pc -> .pc)
464 ("pkg-config" ,pkg-config)))
465 (synopsis "Docker container component library, and daemon")
466 (description "This package provides a framework to assemble specialized
467 container systems. It includes components for orchestration, image
468 management, secret management, configuration management, networking,
470 (home-page "https://mobyproject.org/")
471 (license license:asl2.0)))
473 (define-public docker-cli
476 (version %docker-version)
481 (url "https://github.com/docker/cli.git")
482 (commit (string-append "v" version))))
483 (file-name (git-file-name name version))
486 "1ivisys20kphvbqlazc3bsg7pk0ykj9gjx5d4yg439x4n13jxwvb"))))
487 (build-system go-build-system)
489 `(#:import-path "github.com/docker/cli"
490 ;; TODO: Tests require a running Docker daemon.
493 (modify-phases %standard-phases
494 (add-before 'build 'setup-environment-2
496 ;; Respectively, strip the symbol table and debug
497 ;; information, and the DWARF symbol table.
498 (setenv "LDFLAGS" "-s -w")
500 ;; Make build reproducible.
501 (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
502 (symlink "src/github.com/docker/cli/scripts" "./scripts")
503 (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")
507 (invoke "./scripts/build/dynbinary")))
509 (lambda* (#:key make-flags tests? #:allow-other-keys)
510 (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
512 ;; Use the newly-built docker client for the tests.
513 (with-directory-excursion "src/github.com/docker/cli"
514 ;; TODO: Run test-e2e as well?
515 (apply invoke "make" "-f" "docker.Makefile" "test-unit"
516 (or make-flags '())))
519 (lambda* (#:key outputs #:allow-other-keys)
520 (let* ((out (assoc-ref outputs "out"))
521 (out-bin (string-append out "/bin")))
523 (install-file "docker" out-bin)
528 ("pkg-config" ,pkg-config)))
529 (synopsis "Command line interface to Docker")
530 (description "This package provides a command line interface to Docker.")
531 (home-page "https://www.docker.com/")
532 (license license:asl2.0)))
541 (url "https://github.com/savoirfairelinux/cqfd.git")
542 (commit (string-append "v" version))))
543 (file-name (git-file-name name version))
546 "1z4v16lbpbwd5ykawizdclpryp2k006lbk2mv427a4b3nvcd9wik"))))
547 (build-system gnu-build-system)
549 ;; The test suite requires a docker daemon and connectivity.
552 (modify-phases %standard-phases
556 (lambda* (#:key outputs #:allow-other-keys)
557 (let ((out (assoc-ref outputs "out")))
558 ;; Fix the directory of the bash completion.
559 (substitute* "Makefile"
560 (("completionsdir=.*$")
561 (string-append "completionsdir=" out
562 "/etc/bash_completion.d; \\\n")))
563 (invoke "make" "install"
564 (string-append "PREFIX=" out))))))))
565 (home-page "https://github.com/savoirfairelinux/cqfd")
566 (synopsis "Convenience wrapper for Docker")
567 (description "cqfd is a Bash script that provides a quick and convenient
568 way to run commands in the ecurrent directory, but within a Docker container
569 defined in a per-project configuration file.")
570 (license license:gpl3+)))