Compare commits

...

981 Commits

Author SHA1 Message Date
unclejack
d344625847 Bump version to v1.3.3 2014-12-11 17:37:17 +02:00
Hans Rødtang
496c2748cf Updated cover tool import path.
Signed-off-by: Hans Rødtang <hansrodtang@gmail.com>
2014-12-11 17:37:17 +02:00
Tibor Vass
ee8504bc5a docs: Add release notes
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-12-10 18:19:10 -05:00
Alexandr Morozov
994e4a1c69 Change path breakout detection logic in archive package
Fixes #9375

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>

Conflicts:
	integration-cli/docker_cli_cp_test.go
		removed extra test
2014-12-09 23:16:03 +02:00
Arnaud Porterie
0de96a8163 Fix client-side HTTP hijacking over TLS
Properly CloseWrite() the client socket once done with stdin when using
TLS connection (this used to rely on an erroneous type assertion).

Fixes #8658.
Fixes #8642.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Signed-off-by: Michael Crosby <crosby.michael@gmail.com>
2014-12-09 14:56:17 -05:00
Michael Crosby
c8fc8768b6 Flush stdin from within chroot archive
This makes sure that we don't buffer in memory and that we also flush
stdin from diff as well as untar.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Conflicts:
	pkg/chrootarchive/diff.go
2014-12-09 14:56:17 -05:00
Lewis Marshall
f2008c5359 Fix chroot untar for zero padded archive from slow reader
Signed-off-by: Lewis Marshall <lewis@lmars.net>
2014-12-09 14:56:16 -05:00
unclejack
acf1720b3f validate image ID properly & before load
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2014-12-09 14:56:16 -05:00
Arnaud Porterie
0e9a7bc3ce Add integration test for xz path issue
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>

Conflicts:
	integration-cli/docker_cli_build_test.go
2014-12-09 14:56:16 -05:00
Michael Crosby
313a1b7620 Decompress archive before streaming the unpack in a chroot
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Conflicts:
	pkg/archive/archive.go
	pkg/chrootarchive/archive.go
2014-12-09 14:56:16 -05:00
Michael Crosby
62d83404b5 Update chroot apply layer to handle decompression outside chroot
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Conflicts:
	pkg/archive/diff.go
	pkg/chrootarchive/archive.go
2014-12-09 14:56:16 -05:00
Cristian Staretu
aef842e7df Add build tests covering extraction in chroot
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2014-12-09 14:56:16 -05:00
unclejack
e629e255d8 integ-cli: add test for links in volumes
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2014-12-09 14:56:16 -05:00
unclejack
134f8e6b47 integ-cli: add build test for absolute symlink
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2014-12-09 14:56:16 -05:00
Tibor Vass
1cd89729d5 Add another symlink breakout test
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-12-09 14:56:16 -05:00
Tibor Vass
566146bc13 symlink: add more tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-12-09 14:56:16 -05:00
Tibor Vass
1ebafeb635 symlink: cleanup names and break big test into multiple smaller ones
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-12-09 14:56:16 -05:00
Tibor Vass
18193ae0a3 Refactor of symlink tests to remove testdata dir
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-12-09 14:56:16 -05:00
Tianon Gravi
cd745d5c6e Simplify FollowSymlinkInScope based on Go 1.3.3's EvalSymlinks
Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-12-09 14:56:16 -05:00
Tibor Vass
6f514d28c0 Merge pull request #9316 from tiborvass/bump_v1.3.2
Bump v1.3.2
2014-11-24 16:49:28 -05:00
Tibor Vass
39fa2faad2 Bump to version v1.3.2
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-24 12:38:01 -05:00
Tibor Vass
324953d74a docs: Add 1.3.2 release notes
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-24 12:38:01 -05:00
Tibor Vass
b256616589 archive: do not call FollowSymlinkInScope in createTarFile
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-24 11:51:37 -05:00
unclejack
409f65bfd1 pkg/chrootarchive: provide TMPDIR for ApplyLayer
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-24 11:51:37 -05:00
Derek McGowan
87f59e3802 Skip V2 registry and immediately fallback to V1 when mirrors are provided
Since V2 registry does not yet implement mirrors, when mirrors are given automatically fallback to V1 without checking V2 first.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-11-14 15:30:58 -08:00
Tibor Vass
c650d17a26 Rewrite documentation for insecure registries
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	docs/sources/reference/commandline/cli.md
2014-11-14 14:20:19 -08:00
Tibor Vass
5e2d02ab73 Add the possibility of specifying a subnet for --insecure-registry
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	registry/endpoint.go
2014-11-14 14:20:19 -08:00
Tibor Vass
eb3738347a registry: parse INDEXSERVERADDRESS into a URL for easier check in isSecure
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-14 14:20:19 -08:00
Tibor Vass
6152460c1e Put mock registry address in insecureRegistries for unit tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	registry/registry_mock_test.go
2014-11-14 14:20:19 -08:00
Tibor Vass
1527979e87 registry: refactor registry.IsSecure calls into registry.NewEndpoint
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	registry/endpoint.go
	registry/endpoint_test.go
	registry/registry_test.go
2014-11-14 14:05:31 -08:00
Tibor Vass
04175d0763 archive: prevent breakout in ApplyLayer
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-14 23:45:37 +02:00
Tibor Vass
a111eea20c archive: prevent breakout in Untar
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-14 23:45:29 +02:00
Tibor Vass
ea361c0476 archive: add breakout tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	pkg/archive/archive.go
		fixed conflict which git couldn't fix with the added BreakoutError
2014-11-14 23:44:20 +02:00
Thomas Orozco
967f80f3cc Fix: Failed Start breaks VolumesFrom
Running parseVolumesFromSpec on all VolumesFrom specs before initialize
any mounts endures that we don't leave container.Volumes in an
inconsistent (partially initialized) if one of out mount groups is not
available (e.g. the container we're trying to mount from does not
exist).

Keeping container.Volumes in a consistent state ensures that next time
we Start() the container, it'll run prepareVolumes() again.

The attached test demonstrates that when a container fails to start due
to a missing container specified in VolumesFrom, it "remembers" a Volume
that worked.

Fixes: #8726

Signed-off-by: Thomas Orozco <thomas@orozco.fr>

Conflicts:
	integration-cli/docker_cli_start_test.go
		cli integration test
2014-11-12 00:14:04 +02:00
unclejack
8d90b0faf8 don't call reexec.Init from chrootarchive
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-11 23:20:16 +02:00
Tibor Vass
3ac6394b80 pkg/chrootarchive: pass TarOptions via CLI arg
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-11-11 23:20:09 +02:00
unclejack
0357b26c1b add pkg/chrootarchive and use it on the daemon
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-11 23:20:02 +02:00
unclejack
1d4a82365b pkg/archive: add interface for Untar
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-11 23:19:54 +02:00
Josh Hawn
3ab5251f56 Use archive.CopyWithTar in vfs.Create
The vfs storage driver currently shells out to the `cp` binary on the host
system to perform an 'archive' copy of the base image to a new directory.
The archive option preserves the modified time of the files which are created
but there was an issue where it was unable to preserve the modified time of
copied symbolic links on some host systems with an outdated version of `cp`.

This change no longer relies on the host system implementation and instead
utilizes the `CopyWithTar` function found in `pkg/archive` which is used
to copy from source to destination directory using a Tar archive, which
should correctly preserve file attributes.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
2014-11-11 23:19:43 +02:00
unclejack
d51a02091c pkg/reexec: move reexec code to a new package
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

Conflicts:
	integration/runtime_test.go
		fixed imports
2014-11-11 23:19:34 +02:00
Michael Crosby
0573b17b24 Add AppArmorProfile to container inspect json
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-10 21:04:17 +02:00
Michael Crosby
c9379eb3fb Move security opts to HostConfig
These settings need to be in the HostConfig so that they are not
committed to an image and cannot introduce a security issue.

We can safely move this field from the Config to the HostConfig
without any regressions because these settings are consumed at container
created and used to populate fields on the Container struct.  Because of
this, existing settings will be honored for containers already created
on a daemon with custom security settings and prevent values being
consumed via an Image.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-10 21:04:01 +02:00
unclejack
662ca4114d pkg/symlink: avoid following out of scope
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-10 17:57:54 +02:00
shuai-z
1d1b813d25 removed redundant Clean
The doc (or src) says: The result is Cleaned.

http://golang.org/pkg/path/filepath/#Join

Signed-off-by: shuai-z <zs.broccoli@gmail.com>
2014-11-10 17:57:01 +02:00
Alexandr Morozov
fd9c2ae27d Fix deadlock in ps exited filter
Fixes #8909

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>

Conflicts:
	integration-cli/docker_cli_ps_test.go
		fixed merge issue caused by missing tests
2014-11-07 16:35:50 +02:00
unclejack
09c38a8d43 bump fpm to 1.3.2
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-07 16:18:53 +02:00
Tibor Vass
86292adbd9 Merge pull request #8861 from tiborvass/bump_v1.3.1
Bump v1.3.1
2014-10-30 12:43:43 -04:00
Tibor Vass
4e9bbfa900 Bump to version v1.3.1
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-10-30 09:44:46 -04:00
Tibor Vass
e6efbd6596 Fix login command
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-10-30 09:17:11 -04:00
Erik Hollensbe
9fc8b7f4e1 builder: Restore /bin/sh handling in CMD when entrypoint is specified with JSON
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-30 09:17:11 -04:00
Erik Hollensbe
463297ffe9 builder: whitelist verbs useful for environment replacement.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-30 09:17:11 -04:00
Erik Hollensbe
2dac82eb82 builder: handle escapes without swallowing all of them.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-30 09:17:11 -04:00
Erik Hollensbe
7f8cdeb18b builder: some small fixups + fix a bug where empty entrypoints would not override inheritance.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-30 09:17:11 -04:00
Tibor Vass
3d287811d7 Docs edits for dropping SSLv3 and under + release notes for 1.3.1
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	docs/sources/index.md
2014-10-28 10:42:30 -04:00
Erik Hollensbe
21ab75afe0 builder: handle cases where onbuild is not uppercase.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-21 17:08:05 -04:00
Brian Goff
66fba7c46e Clean volume paths
Fixes #8659

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2014-10-20 19:11:44 -04:00
Alexandr Morozov
ff325bcb2f Don't write pull output to stdout on container creating
Fixes #8632

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-10-20 17:35:43 -04:00
Erik Hollensbe
cf23053eb1 builder: fix escaping for ENV variables.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-20 16:53:37 -04:00
Daniel, Dao Quang Minh
8caacb18f8 Avoid fallback to SSL protocols < TLS1.0
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)

Conflicts:
	registry/registry.go
2014-10-20 16:51:06 -04:00
Tianon Gravi
7d9ccc2636 Fix more missing HOME references
Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-10-20 16:51:06 -04:00
Jessica Frazelle
ada9ac7b13 Setting iptables=false should propagate to ip-masq=false
Signed-off-by: Jessica Frazelle <jess@docker.com>
2014-10-20 16:51:06 -04:00
Tibor Vass
e134f1f74a Do not verify certificate when using --insecure-registry on an HTTPS registry
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	registry/registry.go
	registry/registry_test.go
	registry/service.go
	registry/session.go
2014-10-20 16:51:06 -04:00
Michael Crosby
f43e77fc12 Don't hard code true for auth job
Signed-off-by: Michael Crosby <michael@docker.com>

Conflicts:
	registry/service.go
2014-10-20 16:51:05 -04:00
Michael Crosby
c66196a9dc Expand documentation for --insecure-registries
Signed-off-by: Michael Crosby <michael@docker.com>
2014-10-20 16:51:05 -04:00
Michael Crosby
c0598aced0 Refactor IsSecure change
Fix issue with restoring the tag store and setting static configuration
from the daemon. i.e. the field on the TagStore struct must be made
internal or the json.Unmarshal in restore will overwrite the insecure
registries to be an empty struct.

Signed-off-by: Michael Crosby <michael@docker.com>

Conflicts:
	graph/pull.go
	graph/push.go
	graph/tags.go
2014-10-20 16:51:05 -04:00
unclejack
f9b4bfa59b make http usage for registry explicit
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

Conflicts:
	daemon/config.go
	daemon/daemon.go
	graph/pull.go
	graph/push.go
	graph/tags.go
	registry/registry.go
	registry/service.go
2014-10-20 16:51:05 -04:00
Michael Crosby
c78b920e01 Merge pull request #8323 from crosbymichael/bump_v1.3.0
Bump to version 1.3.0
2014-10-16 10:08:54 -07:00
Michael Crosby
c78088fe3d Bump to version 1.3.0
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-15 19:15:24 +00:00
Michael Crosby
87bd2da5d8 Merge branch 'master' into bump_v1.3.0 2014-10-15 19:15:13 +00:00
Michael Crosby
9a82713772 Merge pull request #8578 from erikh/fix_slash
builder: Handle trailing \ appropriately.
2014-10-15 12:11:37 -07:00
Alexandr Morozov
abec82bdee Merge pull request #8579 from erikh/builder_html_panic
builder: handle anything we cannot parse the command for as a fatal error
2014-10-15 12:01:52 -07:00
Fred Lifton
73792969e6 Merge pull request #8582 from SvenDowideit/api-docs-link-to-basics-page
The basics page moved, update link.
2014-10-15 11:34:25 -07:00
Erik Hollensbe
3f2eb353bd builder: provide a friendly message on parser errors
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-15 18:08:23 +00:00
Fred Lifton
9c6346e9b2 Merge pull request #8583 from SvenDowideit/minimal-curl-command-to-tls-docker-socket
Add a little info on how to talk to the TLS encrypted Docker Socket
2014-10-15 11:01:05 -07:00
Alexandr Morozov
de5b1b8bb0 Merge pull request #8580 from erikh/filter_comments_first
builder: strip blank lines before processing any line continuations.
2014-10-15 11:00:31 -07:00
Erik Hollensbe
63637b9d27 builder: handle anything we cannot parse the command for as a fatal error.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-15 08:47:15 +00:00
Erik Hollensbe
96f342f703 builder: comments should also be elided in the middle of statements following a line continuation.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-15 08:44:14 +00:00
Sven Dowideit
1c68de798f Add a little info on how to talk to the TLS encrypted Docker Socket
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-15 17:24:53 +10:00
Sven Dowideit
a64ff0bf7a The basics page moved, update link.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-15 16:48:43 +10:00
Erik Hollensbe
a1ef2207dd builder: strip blank lines before processing any line continuations.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-15 04:00:17 +00:00
Erik Hollensbe
7fa449191c builder: Handle trailing \ appropriately.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-15 03:08:18 +00:00
Michael Crosby
dc243c812b Merge pull request #8564 from tiborvass/remove-docker-dot-io
change docs.docker.io to docs.docker.com in install script
2014-10-14 10:53:10 -07:00
Tibor Vass
e5e0baa6d4 change docs.docker.io to docs.docker.com in install script
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-10-14 13:45:26 -04:00
Michael Crosby
a29837020b Merge pull request #8563 from crosbymichael/remove-key-create
Remove client key.json generation for trust
2014-10-14 10:45:15 -07:00
Michael Crosby
712e8da885 Remove client key.json generation for trust
This removes the key generation for trust from main while it is not
being consumed.  The problem is that because this is being set in main
if a user runs as root initially the files will be owned by root.  Later
if the user sets up the docker group they are unable to read the keys.
This is half a user error and documentation problem and the other half
is management.

We decided to remove this code for now while it is not being used and
will revisit it later when the consuming features are added.  A few
options are to generate lazily and provide a clear error message on an
EPERM so that the user knows what is wrong and can correct the
permissions.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-14 17:16:45 +00:00
James Turnbull
23be0486f6 Merge pull request #8558 from fgrehm/patch-4
docs: Fix some minor typos on dockerlinks guide
2014-10-14 10:01:45 -04:00
Fabio Rehm
06d633e1f6 docs: Fix some minor typos on dockerlinks guide
Signed-off-by: Fabio Rehm <fgrehm@gmail.com>
2014-10-14 10:15:35 -03:00
Victor Vieux
95b67895c4 Merge pull request #8553 from tianon/fix-over-aggressive-shell-interpolation-regex
Fix builder from being over-aggressive on ${}
2014-10-14 00:30:03 -07:00
Tianon Gravi
24189b2c36 Fix builder from being over-aggressive on ${}
`${SOME_VAR%pattern}` was turning into `SOME_VAL%pattern}` which the shell would then balk at.

I've updated the `TOKEN_ENV_INTERPOLATION` regex to account for this (ie, if `${` is used, it _must_ also match the closing `}`), and renamed the variable to not be exported (since it's not used outside the function following it).

I also added comments for the bits of `tokenEnvInterpolation` so they're easier to follow. 😄

Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-10-14 00:58:55 -06:00
Victor Vieux
0ab2f19278 Merge pull request #8552 from crosbymichael/update-libcontainer-oct2
Update to libcontainer 8d1d0ba38a7348c5cfdc05aea3b
2014-10-13 23:43:06 -07:00
Michael Crosby
018ce19b31 Update to libcontainer 8d1d0ba38a7348c5cfdc05aea3b
This fixes issues where the apparmor profile is not applied to processes
via docker exec.  As a side effect the parent processes were unable to
kill the additional child processes because of the profile mismatch.

Easy way to reproduce on an apparmor system:
docker run -ti debian:jessie bash
ps auxZ
- look at the labels

- in another shell
docker exec <name> sleep 1000

- go back to the first container and
ps auxZ
- make sure all processes have the correct docker-default profile

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-14 06:24:38 +00:00
Michael Crosby
9d1c9a4075 Merge pull request #8548 from crosbymichael/config-path
Write s3cfg to $HOME
2014-10-13 20:45:16 -07:00
Michael Crosby
e0a1df8e68 Write s3cfg to $HOME
Because of the base image change, $HOME is not always / and we need to
write to the proper $HOME within the container to complete the release
process.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-14 03:34:24 +00:00
Michael Crosby
e4976b8cc1 Merge pull request #8545 from fredlf/1.3release-notes
Adding release notes for 1.3.
2014-10-13 19:30:33 -07:00
Michael Crosby
2c5ad1ac3e Merge pull request #8547 from erikh/onbuild-cmd
builder: ONBUILD triggers were not accurately being executed in JSON cases
2014-10-13 19:29:16 -07:00
Sven Dowideit
18b507c49e Merge pull request #8226 from SvenDowideit/more-daemon-option-information
More daemon option information
2014-10-14 12:06:14 +10:00
SvenDowideit
5bcff59feb Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
Add some information about the storage and execution driver choices

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-10-14 12:05:09 +10:00
Erik Hollensbe
1150c1639a builder: ONBUILD triggers were not accurately being executed in JSON cases.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-14 01:59:45 +00:00
Sven Dowideit
587e2f1ddc Merge pull request #8529 from SvenDowideit/update-version-dropdown-on-404
Remove version selector and edit on Github on search page, as it only se...
2014-10-14 11:55:12 +10:00
Sven Dowideit
5bf3ac5738 Remove version selector and edit on Github on search page, as it only searches the latest docs
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-14 11:54:41 +10:00
Sven Dowideit
9d5e3a54a0 Merge pull request #8525 from duglin/Issue4789
Add more info about the LINK env vars created
2014-10-14 11:24:17 +10:00
Fred Lifton
30cfa148b9 Adding release notes for 1.3.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-10-13 17:17:41 -07:00
Tibor Vass
839660ada1 Merge pull request #8541 from crosbymichael/update-libcontainer-oct1
Update libcontainer to 4f409628d80b9842004a3f17c92
2014-10-13 17:54:27 -04:00
Fred Lifton
939227a81a Merge pull request #8462 from SvenDowideit/document-how-to-add-a-new-document
Mention the mkdocs.yml file for adding new documents
2014-10-13 13:15:00 -07:00
Fred Lifton
c2096d7096 Merge pull request #8530 from SvenDowideit/auto-scroll-to-auto-index-section-the-user-requested
Turn off editing for auto-generated index pages, and scroll the user to the right section
2014-10-13 13:12:05 -07:00
Fred Lifton
66b9694b58 Merge pull request #8532 from SvenDowideit/demote-readme.md-header
README.md is a sub-section in how to build automated builds
2014-10-13 13:02:41 -07:00
Michael Crosby
8fedf718ce Update libcontainer to 4f409628d80b9842004a3f17c92
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-13 19:53:20 +00:00
Fred Lifton
547c42d8d0 Merge pull request #8528 from SvenDowideit/hide-side-toc-for-search
Hide the empty sidebar TOC on the search page
2014-10-13 12:13:06 -07:00
Fred Lifton
3040c8b759 Merge pull request #8527 from SvenDowideit/dissalow-robots-except-for-docs.docker.com
start sending robots.txt (and humans.txt) again, and set to dissallow if...
2014-10-13 12:12:18 -07:00
Fred Lifton
6ce3967f8f Merge pull request #8517 from sequenceiq/master
docs: fixing docker.io api
2014-10-13 12:09:39 -07:00
Fred Lifton
ce669297df Merge pull request #8503 from aanand/tlsverify-environment-variable
Add DOCKER_TLS_VERIFY environment variable, equivalent to --tlsverify flag
2014-10-13 10:20:10 -07:00
James Turnbull
42b217044a Merge pull request #8435 from SvenDowideit/explain-docker-attach-more
Add more info on attach inspired by discussion in #2855
2014-10-13 13:19:22 -04:00
James Turnbull
e3101a3508 Merge pull request #8523 from duglin/FixLinkCmdLine
Fix href in docs w.r.t. cgroups freezer pointer
2014-10-13 13:18:49 -04:00
James Turnbull
8a32aa26c1 Merge pull request #8524 from duglin/Regardless
Fix typo: reguardless should be regardless
2014-10-13 13:18:21 -04:00
James Turnbull
fe03da7da8 Merge pull request #8507 from duglin/Issue3087
Add some docs about which env vars are defined in new containers
2014-10-13 13:13:43 -04:00
Aanand Prasad
19fb942d36 Add DOCKER_TLS_VERIFY environment variable, equivalent to --tlsverify flag
This makes it possible to make the Docker client "secure by default"
without wrapping the binary in a shell alias so that `--tlsverify` is
always passed.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2014-10-13 11:49:26 +01:00
Sven Dowideit
801edfa9b8 Add more info on attach inspired by discussion in #2855
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-13 17:30:08 +10:00
Sven Dowideit
3d2f10e28a Mention the mkdocs.yml file for adding new documents
and move the complicated discussion about branches lower down,
hopefully most won't need to know

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-10-13 17:06:18 +10:00
Sven Dowideit
3732cd6612 README.md is a sub-section in how to build automated builds
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-13 17:00:58 +10:00
Sven Dowideit
687215c32f Turn off editing for auto-generated index pages, and scroll the user to the right section
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-13 16:32:18 +10:00
Sven Dowideit
d883fb66b0 Hide the empty sidebad TOC on the search page
This uses @dnephin's changes to the base.html (thank you!)

and then adds the hide_toc: page meta

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-13 14:10:29 +10:00
Sven Dowideit
44e9a59665 start sending robots.txt (and humans.txt) again, and set to dissallow if its not the real docs site
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-13 13:53:16 +10:00
Doug Davis
61387427cb Add more info about the LINK env vars created
@SvenDowideit see what you think. I'd like to get your take on this
before I submit the PR.

Closes #4789

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-12 18:34:18 -07:00
Doug Davis
ba7038c8d2 Fix typo: reguardless should be regardless
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-12 14:41:24 -07:00
Doug Davis
b10e11f30e Fix href in docs w.r.t. cgroups freezer pointer
Apparently, the [...] and (http...) need to be right after each other instead
of on different lines.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-12 12:59:46 -07:00
Lajos Papp
137bad4b48 docs: fixing docker.io api
Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com>
2014-10-12 09:05:58 +02:00
unclejack
7fa7c42ce2 Merge pull request #8508 from vbatts/vbatts-too_many_open_files
cleaner handling of client socket access
2014-10-11 11:16:23 +03:00
Jessie Frazelle
9f482a66ab Merge pull request #8393 from dmcgowan/provenance_pull_enhance
Make V2 code more defensive against malformed content
2014-10-10 17:19:59 -07:00
Victor Vieux
246ec5dd06 Merge pull request #8505 from crosbymichael/ps-name
Improve ps name parsing
2014-10-10 17:08:35 -07:00
Vincent Batts
fb7ceeb170 cleaner handling of client socket access
In the go stdlib net/http Transport, the used connections are cached
when idled. This behaviour is intended for TCP connections and does not
behave correctly for unix sockets. Despite the
DefaultMaxIdleConnsPerHost being 2, the idled connections are held open
during a session. For large sessions like `docker rm $(docker ps -a -q)`
of thousands of containers, it will cause the client _and_ the server to
open too many fails and have failures.

Having keep alives not used for only unix sockets is a work around for
this stdlib issue.

Also this includes disabling compression when communicating over the
local unix socket too.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-10-10 19:58:49 -04:00
Derek McGowan
3be4551a91 Enable V2 pull flow
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:09:56 -07:00
Derek McGowan
85fd8213af Update verification message
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:29 -07:00
Derek McGowan
73a9089306 Support tarsum dev version to fix issue with mtime
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:29 -07:00
Derek McGowan
15d5c7f10f Update manifest format to rename blobsums and use arrays of dictionaries
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:29 -07:00
Derek McGowan
456f493659 Add status message for V2 pull
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:29 -07:00
Derek McGowan
7d21ea6627 Update pull message and log
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:28 -07:00
Derek McGowan
a152f37674 Use direct registry url
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:28 -07:00
Derek McGowan
e8b8cf61a9 Make V2 code more defensive against malformed content
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-10 16:04:28 -07:00
Doug Davis
7d1e197f25 Add some docs about which env vars are defined in new containers
@SvenDowideit FYI

Closes #3087

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-10 15:40:52 -07:00
Michael Crosby
b10dfb7de3 Import ps name parsing for default name
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-10 22:18:25 +00:00
Brice Jaglin
4a5cefa173 on truncated output, show canonical name rather than first name
Docker-DCO-1.1-Signed-off-by: Brice Jaglin <bjaglin@teads.tv> (github: bjaglin)
2014-10-10 08:12:15 +02:00
Brice Jaglin
0099b5e68c reflect changes introduced in d2ffcd9 in docs
Docker-DCO-1.1-Signed-off-by: Brice Jaglin <bjaglin@teads.tv> (github: bjaglin)
2014-10-10 08:12:12 +02:00
Sven Dowideit
248ec5d74e Merge pull request #8384 from rhatdan/selinux-opts
Fix security-opt docs
2014-10-10 10:52:17 +10:00
Tianon Gravi
3b41439262 Merge pull request #8496 from jfrazelle/update-desktop-examples
Update desktop integration examples to be more awesome.
2014-10-09 18:44:03 -06:00
Jessica Frazelle
8aa468ef56 Update desktop integration examples to be more up to date.
Chromium > Iceweasel and cool new gparted example.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-09 17:13:13 -07:00
Victor Vieux
72d8d94284 Merge pull request #8497 from aluzzardi/disable-stable-ip
Disable stable IPs.
2014-10-09 15:54:33 -07:00
Victor Vieux
88a41aa7d1 Merge pull request #8470 from fgrehm/patch-3
docs: Remove `Detach` parameter from Exec Create example
2014-10-09 15:25:51 -07:00
Andrea Luzzardi
5b8379a434 Disable stable IPs.
Stable IPs causes some regressions in the way people use Docker, see GH#8493.

Reverting it for 1.3, we'll enable it back for the next release.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-09 15:15:17 -07:00
Tibor Vass
d095659c6e Merge pull request #8495 from jpetazzo/8494-fix-debian-frontend-in-getdockercom-script
Add -E flag to sudo (fixes #8494)
2014-10-09 18:05:18 -04:00
Michael Crosby
917529e45e Merge pull request #8482 from jfrazelle/8481-content-type-bump-v
Revert #8101 and #7886 (content-type:x-json-stream/line delimited json)
2014-10-09 14:57:15 -07:00
Jérôme Petazzoni
e01e913d80 Add -E flag to sudo (fixes #8494)
Docker-DCO-1.1-Signed-off-by: Jérôme Petazzoni <jerome@docker.com> (github: jpetazzo)
2014-10-09 14:54:22 -07:00
Jessica Frazelle
b66ac6a809 Revert "Fix line delimited JSON response"
This reverts commit d2f75a3040.

Conflicts:
	integration-cli/docker_api_events_test.go

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-09 13:46:21 -07:00
Jessica Frazelle
4c6b7cd1b5 Revert "Change content-type for json stream to application/x-json-stream."
This reverts commit 10ab2089ce.

Conflicts:
	api/client/utils.go
	docs/sources/reference/api/docker_remote_api.md

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-09 13:17:47 -07:00
Dan Walsh
a260772e48 Fix security-opt docs
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-10-09 15:18:28 -04:00
Fred Lifton
2f5f437bc1 Merge pull request #8419 from nhsiehgit/dockerfiletut
Dockerfiletut
2014-10-09 10:15:10 -07:00
Fred Lifton
950f271ee4 Merge pull request #8461 from SvenDowideit/copy-specific-files-from-context
Add a best practice to reduce cache invalidations
2014-10-09 10:03:50 -07:00
Michael Crosby
4eb812e042 Merge pull request #8457 from jfrazelle/pr_8455
Check /etc/resolv.conf every time for 127.* content
2014-10-08 16:21:14 -07:00
Jessica Frazelle
dbe6c6651e cleanup resolve.conf code
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-08 15:15:51 -07:00
Michael Crosby
0486bd022e Merge pull request #8450 from dqminh/fix-proxy-exit
dont close proxy's stdout/stderr prematurely
2014-10-08 14:20:33 -07:00
Andrea Luzzardi
d7bcc099be Merge pull request #8475 from cpuguy83/fix_create_phantom_volumes_on_container_restart
Fixes re-creating volume on (re)start
2014-10-08 13:58:56 -07:00
Andrea Luzzardi
c417921f78 Merge pull request #8472 from cpuguy83/fix_volume_refs_on_daemon_restore
Restore volume refs after daemon restart
2014-10-08 13:58:30 -07:00
Nathan Hsieh
6a874cf711 added fixes to address comments
Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>
2014-10-08 13:46:44 -07:00
Nathan Hsieh
c257dcc9a4 Squashed commit of the following:
commit 3f9e9185fe7ee51f2fe55f0fc0d4fffdc4f289dc
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Mon Oct 6 10:57:35 2014 -0700

    changed the title of back buttons

commit f86934424e85931ec293e711ceaa93ee920828fb
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Mon Oct 6 10:53:15 2014 -0700

    Finished level 2, refactored tests

commit 8f502bce05293cccaf200b69ce5f5826eee72484
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Mon Oct 6 08:52:37 2014 -0700

    stylized better and added level 2

commit 07b2276b346c34c0cc0faa57500c40e120e77888
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Fri Oct 3 18:17:29 2014 -0700

    broke tutorial tests styles

commit 35d84147dc2f65b0ffeea5faf304add903219b1e
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Fri Oct 3 17:23:48 2014 -0700

    structured test level1 md file

commit 808d01b0d55d67eb1017f290a29da6c7d38565f2
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Fri Oct 3 17:15:46 2014 -0700

    Modified files and integrated tutorial through new page

commit 0f0093f2882489c3eeb6f8870f2b8aa64dc939a3
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Thu Oct 2 14:34:44 2014 -0700

    more refactoring

commit 5a9b98e55ebd455ccf2c0ced20f984545a0b6d71
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Thu Oct 2 11:46:58 2014 -0700

    clean js code

commit af3bbd8d5e1dffdaa1780f83b909ff566906e513
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Thu Oct 2 11:26:39 2014 -0700

    level 1 cleanup

commit c4852a7766ab4fbd978d65c8352ace05eb427ef5
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Thu Oct 2 11:20:17 2014 -0700

    fixed up fill-in level1

commit 7f02d80942549dec9c05f784b777fcb32d5bb81b
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date:   Wed Oct 1 17:45:42 2014 -0700

    added dockerfile tut, stylized lesson1 Questions

Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>
2014-10-08 13:46:44 -07:00
Nathan Hsieh
8ceb213b3e merged conflicting commits
Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>
2014-10-08 13:44:21 -07:00
Brian Goff
c985302c5c Fixes re-creating volume on (re)start
When a container is restarted all the volume configs are parsed again.
Even if the volume was already handled in a previous start it was still
calling "FindOrCreateVolume" on the volume repo causing a new volume to
be created.

This wasn't being detected because as part of the mount initialization
it checks to see if the the _mount_ was already initialized, but this
happens after the parsing of the configs.
So a check is added during parsing to skip a volume which was already
created for that container.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2014-10-08 16:25:51 -04:00
Brian Goff
9acf7c765c Restore volume refs after daemon restart
Volume refs were not being restored on daemon restart.
This made it possible to remove a volume being used by other containers
after a daemon restart.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2014-10-08 14:17:27 -04:00
Daniel, Dao Quang Minh
3b9d88210e pass extra file to child process as status handler
When stdout/stderr is closed prematurely, the proxy's writes to stdout/stderr
(i.e. `log.Errorf/log.Printf`) will returns with EPIPE error, and go runtime
will terminate the proxy when stdout/stderr writes trigger 10 EPIPE errors.

instead of using stdout/stderr as the status handler, we pass an extra file to
the child process and write `0\n` or `1\nerror message` to it and close it
after. This allow the child process to handle stdout/stderr as normal.

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
2014-10-08 12:53:43 -04:00
Fabio Rehm
2fd0e8eb5f docs: Remove Detach parameter from Exec Create example
Signed-off-by: Fabio Rehm <fgrehm@gmail.com>
2014-10-08 10:31:12 -03:00
Victor Vieux
0d5daa4a8f Merge pull request #8463 from jfrazelle/fix-invalid-tag-test
Fix Tag Test for longer tags
2014-10-08 01:07:24 -07:00
Jessica Frazelle
de32f48e66 Fix Tag Test for longer tags
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-07 19:37:08 -07:00
Victor Vieux
60908acff6 Merge pull request #8447 from burke/bump-tag-char-limit
Increase the tag length limit from 30 to 128
2014-10-07 18:31:35 -07:00
Sven Dowideit
a36ba19cca Add a best practice to reduce cache invalidations
inspired by https://github.com/docker-training/docker-fundamentals/pull/206

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2014-10-08 11:26:48 +10:00
Victor Vieux
7f22fc32d5 Merge pull request #8431 from aluzzardi/b-alloc-network-error-handling
Container#AllocateNetwork: Simplify error handling.
2014-10-07 18:21:28 -07:00
James Turnbull
c2428ff865 Merge pull request #8437 from SvenDowideit/un-pto-sven-oct-2014
back from camping, and making fred the docs 'guy in charge'
2014-10-07 20:01:26 -04:00
Michael Crosby
989e064d6e Merge pull request #8459 from crosbymichael/entrypoint-parent
Allow child to overwrite entrypoint from parent
2014-10-07 16:57:44 -07:00
Jessie Frazelle
85da74ce5f Merge pull request #8451 from eparis/systemd
Fix system socket/service unit files
2014-10-07 16:54:20 -07:00
Jessica Frazelle
acd511786e Test for check /etc/resolv.conf on every docker run for 127.* content.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-07 16:51:51 -07:00
Michael Crosby
50fa9dffcf Allow child to overwrite entrypoint from parent
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-07 23:45:35 +00:00
Jessie Frazelle
12203e475d Merge pull request #8434 from tiborvass/ignore_invalid_Dockerfile_instructions
Ignore unknown dockerfile instructions
2014-10-07 14:45:51 -07:00
Dan Walsh
9ced509e6d Check /etc/resolv.conf every time for 127.* content
Currently if you start the docker -d on a system with 127.0.0.1 in /etc/resolv.conf
It will set the default dns to 8.8.8.8 8.8.4.4 permanently.

This causes a problem at boot on Fedora machines where NetworkManager has not
populated /etc/resolv.conf before docker gets started.

This fix checks /etc/resolv.conf on every docker run. And only populates
daemon.config.Dns  if the user specified it on the command line.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-10-07 16:19:02 -04:00
Eric Paris
053c3557b3 Fix system socket/service unit files
Two problems how they are today:

In the current systemd unit files it is impossible to have the
docker.service started at system boot.  Instead enableing docker.service
will actually enable docker.socket.  This is a problem, as that means
any container with --restart=always will not launch on reboot.  And of
course as soon as you log in and type docker ps, docker.service will be
launched and now your images are running.  Talk about a PITA to debug!
The fix is to just install docker.service when people ask docker.service
to be enabled.  If an admin wants to enable docker.socket instead, that
is fine and will work just as it does today.

The second problem is a common docker devel workflow, although not
something normal admins would hit.  In this case consider a dev doing
the following:

systemctl stop docker.service

docker -d
[run commands]
[^C]

systemctl start docker.service

Running docker -d (without -F fd://) will clean up the
/var/run/docker.sock when it exits.  Remember, you just ran the docker
daemon not telling it about socket actviation, so cleaning up its socket
makes sense!  The new docker, started by systemd will expect socket
activation, but the last one cleaned up the docker.sock.  So things are
just broken.  You can, today, work around this by restarting
docker.socket.  This fixes it by telling docker.socket that it is
PartOf=docker.service.  So when docker.service is
started/stopped/restarted docker.socket will also be
started/stopped/restarted.  So the above semi-common devel workflow will
be fine.  When docker.service is stopped, so is docker.socket,   docker
-d (without -F fd://) will create and delete /var/run/docker.sock.
Starting docker.service again will restart docker.socket, which will
create the file an all is happy in the word.

Signed-off-by: Eric Paris <eparis@redhat.com>
2014-10-07 14:09:08 -04:00
Burke Libbey
c95b0e0292 Increase the tag length limit from 30 to 128
Signed-off-by: Burke Libbey <burke.libbey@shopify.com>
2014-10-07 11:29:47 -04:00
Sven Dowideit
9b5e6d40f5 back from camping, and making fred the docs 'guy in charge'
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-10-07 15:54:30 +10:00
Sven Dowideit
7813f85e7d Merge pull request #8382 from jamtur01/cli
Multiple fixes to the cli.md document.
2014-10-07 15:07:57 +10:00
Sven Dowideit
8f58025b70 Merge pull request #8304 from davide-ceretti/chore/prettify-docs-update.py
Prettify docs-update.py
2014-10-07 14:30:24 +10:00
Sven Dowideit
40cad37f0a Merge pull request #8341 from unclejack/add_workdir_test
add test for workdir env vars and add docs
2014-10-07 14:27:32 +10:00
Tibor Vass
0a2c481c7f ignore invalid Dockerfile instructions and do not consider "docker-version" a Dockerfile instruction
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-10-06 23:26:59 -04:00
James Turnbull
92a9b87a57 Merge pull request #8426 from proppy/patch-12
google: fix typo
2014-10-06 23:18:54 -04:00
Tibor Vass
9fe1dd3103 Add test for ignoring invalid dockerfile instructions
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-10-06 23:14:25 -04:00
Andrea Luzzardi
300c51c3a4 Container#AllocateNetwork: Simplify error handling.
The defer logic was a little tricky and was hiding one bug: `err` was
being redefined (with `:=`) and thus it escaped the defer error checking
logic.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-06 17:59:12 -07:00
Johan Euphrosine
0a056a31fa google: fix typo
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
2014-10-06 15:28:50 -07:00
Alexandr Morozov
a650ab7f29 Merge pull request #8409 from unclejack/integcli_lint
integcli: lint fixes
2014-10-06 14:32:08 -07:00
unclejack
c0e632246d integcli: lint fixes
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-10-06 23:15:17 +03:00
Victor Vieux
6157af8292 Merge pull request #8416 from LK4D4/fix_build_cache_test
Fix TestBuildCacheADD to check cache in out, not in id
2014-10-06 11:56:18 -07:00
Michael Crosby
128c52f583 Merge pull request #8417 from cpuguy83/8398_fix_automatic_data_copy_for_volumesfrom
volumes copying data unexpectedly
2014-10-06 11:43:41 -07:00
Victor Vieux
40070609da Merge pull request #8369 from vieux/add_test_rm
add test and move one from rm to rmi
2014-10-06 11:30:12 -07:00
Brian Goff
e95b6fb648 Fix #8398 - volumes copying data unexpectedly
Prior to the volumes re-factor, data was not being copied on
volumes-from or host-mounted volumes.
After the re-factor, data was being copied for volumes-from.
This reverts this unintentional change in behavior.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2014-10-06 14:21:46 -04:00
Victor Vieux
3e473c08b4 update test
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-10-06 18:18:25 +00:00
Victor Vieux
7bd482d570 Merge pull request #8370 from duglin/ParserIndent
Fix builder/parser so it keeps some whitespace on split lines.
2014-10-06 10:32:02 -07:00
Michael Crosby
a761698700 Merge pull request #8391 from crosbymichael/disable-v2-registry
Remove registry v2 code path
2014-10-06 10:12:20 -07:00
Fred Lifton
3fc04f36e5 Merge pull request #8343 from duglin/Issue5278
Make fixed font sizes smaller per Issue #5278
2014-10-06 10:11:01 -07:00
Alexandr Morozov
21dff8cbec Fix TestBuildCacheADD to check cache in out, not in id
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-10-06 10:04:10 -07:00
Victor Vieux
887d9238f5 Merge pull request #8408 from tonistiigi/8407-fix-host-header
Fix Host header on stream commands
2014-10-06 09:48:12 -07:00
Victor Vieux
166c56cabd Merge pull request #8413 from tonistiigi/build-content-type
Fix streaming JSON Content-type for postBuild
2014-10-06 09:38:52 -07:00
Tonis Tiigi
30d6ff99fc Fix streaming JSON Content-type for postBuild
See #8101

lineDelim is used by streamJSON() so it needs to be set
before its called.

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
2014-10-06 19:20:10 +03:00
Tonis Tiigi
e457b21db3 Fix Host header on stream commands
Fixes #8407

Setting Host on URL only works if the Request does not
already have its Host property set.

Note that the API version was also swallowed.

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
2014-10-06 17:04:27 +03:00
Doug Davis
9c201c5836 Make fixed font sizes smaller per Issue #5278
Closes #5278

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-06 06:49:33 -07:00
Doug Davis
f440c6b224 Fix builder/parser so it keeps some whitespace on split lines.
If previous line ends with whitespace, or next line starts with whitepsace
we need to preserve a space otherwise things line:
RUN echo\
   hello
will appear as: RUN echohello

Noticed this while looking at #5744 because he had lines ending in &&\

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-03 20:33:12 -07:00
James Turnbull
44264f48e4 Merge pull request #8388 from merty/patch-1
Fixed a typo in "Installing Docker on Mac OS X"
2014-10-03 22:03:50 -04:00
James Turnbull
62391d68a4 Merge pull request #8360 from duglin/Issue5509
Add note to docs about lack of shell processing in JSON form - Issue 5509
2014-10-03 22:03:31 -04:00
James Turnbull
95e169a6a1 Merge pull request #8222 from fredlf/adding_official-repo-guidelines
Edits and fixes based on review.
2014-10-03 22:03:05 -04:00
Andrea Luzzardi
84d9fd37b0 Merge pull request #8392 from jfrazelle/pr_8389
Invalid mount mode for volumes in
2014-10-03 17:22:21 -07:00
Jessica Frazelle
b10b458b6e Add test for invalid mount mode for volumes in.
Closes #8389.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-03 16:17:51 -07:00
Michael Crosby
1c62e0ae4e Remove registry v2 code path
As this feature requires more testing it is much safter to get the
underlying changes into the codebase first then enable the feature in
another release after proper testing and verification can be done.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-03 22:24:14 +00:00
Victor Vieux
d152a93b5f Merge pull request #8297 from aluzzardi/f-stable-ip
Stable Networking: Keep the same network settings during the entire container lifecycle.
2014-10-03 14:19:46 -07:00
Brian Goff
007b4f6340 Fixes bad validMountMode check
Needed to check if the mode was invalid and return error, not valid and
return error.

This didn't get picked up because the existing integration-cli tests
were all either expecting errors when a valid mode was passed in (e.g.
"ro" passed in, we expected an error because it was testing write).  So
modified a test which was testing for "rw" to actually pass in "rw"
instead of assuming the "rw"

Docker-DCO-1.1-Signed-off-by: Brian Goff <bgoff@cpuguy83-mbp.home> (github: cpuguy83)
2014-10-03 16:55:39 -04:00
Andrea Luzzardi
b669025949 Stable MAC addresses: Add support for MAC address restoring.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
Andrea Luzzardi
f1087c5fcf Daemon: Restore network settings at startup.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
Andrea Luzzardi
a487593729 Stable Networking: Keep the same network settings across container restarts.
This change will allocate network settings (IP and public ports) at
container creation rather than start and keep them throughout the
lifetime of the container (i.e. until it gets destroyed) instead of
discarding them when the container is stopped.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
Andrea Luzzardi
deffc572ce Container: Add restore network functionality.
RestoreNetwork() allows the container to restore its NetworkSettings (IP
and public ports).

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
Andrea Luzzardi
ab4188c08d Container: Make allocateNetwork and releaseNetwork public.
Since we are moving network allocation outside of container scope (it
will be managed by create/destroy), those functions need to be
accessible from the outside.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
Andrea Luzzardi
103a4e0676 Network Allocation: Proper rollback in case of failure allocation.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:46:24 -07:00
James Turnbull
ee101c3b2c Multiple fixes to the cli.md document.
*. Fixed headings so the side menu will now be consistent. Some sections
had H3s that were displaying and others did not leaving the left menu
very mismatched.

* Fixed several spelling errors.

* Re-formatted several long lines and badly laid out paragraphs.

* Fixed several double backticks.

* Added backticks to several outputs and variables.

* Removed two issues that are no longer valid.

* Removed several double spaces and extra lines.

Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
2014-10-03 16:28:43 -04:00
Alexandr Morozov
beff5067c8 Merge pull request #8371 from aluzzardi/f-consistent-mac
Support for consistent MAC address.
2014-10-03 13:28:03 -07:00
Andrea Luzzardi
88e21c6a75 Support for consistent MAC address.
Right now, MAC addresses are randomly generated by the kernel when
creating the veth interfaces.

This causes different issues related to ARP, such as #4581, #5737 and #8269.

This change adds support for consistent MAC addresses, guaranteeing that
an IP address will always end up with the same MAC address, no matter
what.

Since IP addresses are already guaranteed to be unique by the
IPAllocator, MAC addresses will inherit this property as well for free.

Consistent mac addresses is also a requirement for stable networking (#8297)
since re-using the same IP address on a different MAC address triggers the ARP
issue.

Finally, this change makes the MAC address accessible through docker
inspect, which fixes #4033.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-10-03 13:22:38 -07:00
Mert Yazıcıoğlu
81cddaaa7d Fixed a typo in "Installing Docker on Mac OS X"
evironment -> environment
2014-10-03 23:18:40 +03:00
Michael Crosby
94da44cacf Merge pull request #8375 from fgrehm/patch-2
docs: Update `docker exec` examples
2014-10-03 11:30:37 -07:00
Michael Crosby
5a627e41ff Merge pull request #8324 from cpuguy83/6231_fix_chunked_encoding
Fix #6231 - Accept chunked encoding on start
2014-10-03 11:27:57 -07:00
Brian Goff
86bfb9bca6 Fix #6231 - Accept chunked encoding on start
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-10-03 14:18:25 -04:00
Michael Crosby
23dc2ca2d5 Merge pull request #8336 from kwk/improve_docs_with_note_about_registry_frontend_web_app
Improve docs with note about registry frontend web app
2014-10-03 11:00:32 -07:00
Michael Crosby
eaaf9e3125 Merge pull request #8320 from dmcgowan/provenance_pull
Official image provenance pull flow
2014-10-03 10:56:54 -07:00
Michael Crosby
6deeb103cf Merge pull request #8372 from cpuguy83/change_volume_containers_to_private
Make volume.Containers private
2014-10-03 10:44:21 -07:00
Doug Davis
98ceae1a84 Add note to docs about lack of shell processing in JSON form
Closes #5509

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-03 05:18:25 -07:00
Fabio Rehm
6480b30a99 docs: Update docker exec examples
Signed-off-by: Fabio Rehm <fgrehm@gmail.com>
2014-10-03 01:13:59 -03:00
Brian Goff
c5e728c953 Make volume.Containers private
Also wrap access in mutex.
Makes sure we don't have any pontential for races in accessing this.
It also doesn't really need to be/shouldn't be in the config.json anyway

Docker-DCO-1.1-Signed-off-by: Brian Goff <bgoff@cpuguy83-mbp.home> (github: cpuguy83)
2014-10-02 20:46:17 -04:00
Derek McGowan
22e59009e4 Add comment for permission and fix wrong format variable
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-02 17:41:57 -07:00
Victor Vieux
c68e6b15a5 add test and move one from rm to rmi
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-10-02 23:39:39 +00:00
Victor Vieux
06b74875b6 Merge pull request #8368 from vieux/fix_docker_rm
docker rm <unknown>
2014-10-02 16:30:37 -07:00
Jessie Frazelle
8a0733ce69 Merge pull request #8351 from kencochrane/8347_fix_broken_doc_build
Fixed issue with docs not getting built due to ssl error.
2014-10-02 15:58:18 -07:00
Victor Vieux
3eaa1c99c1 docker rm <unknown>
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-10-02 22:52:37 +00:00
Victor Vieux
b2ee63000e Merge pull request #8367 from crosbymichael/update-libcontainer-sep9
Update libconatiner to b3570267c7b7995d5d618974d8f
2014-10-02 15:41:06 -07:00
Michael Crosby
193654e3ef Update libconatiner to b3570267c7b7995d5d618974d8f
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-02 22:19:56 +00:00
Jessie Frazelle
45667fb1bb Merge pull request #8364 from tianon/bash-completion-filters
Optimize the bash completion even further
2014-10-02 15:00:01 -07:00
Victor Vieux
34f4144b7f Merge pull request #8358 from docker/6969-reponame-rest-api
Added validity checks for repo name and tag in build job
2014-10-02 14:22:57 -07:00
Tianon Gravi
0597b6445d Optimize the bash completion even further
The biggest/bestest change here is cutting down on the number of calls to Docker in the filtering helpers (`__docker_containers_running`, etc), especially calls to the really heavy `docker images`.

Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-10-02 15:13:37 -06:00
Fred Lifton
36db0a30fa Edits and fixes to Dockerfile Best Practices based on review feedback.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-10-02 14:08:39 -07:00
Michael Scharf
cbb81c30bd add bash completion support for pause and unpause
Signed-off-by: Michael Scharf <github@scharf.gr>
2014-10-02 14:18:47 -06:00
Jessie Frazelle
f69a262464 Merge pull request #8213 from brahmaroutu/pull_status_2404
Print a status message when pull command is executed
2014-10-02 09:56:18 -07:00
Joffrey F
aabba9801a Added validity checks for repo name and tag in build job.
Signed-off-by: Joffrey F <joffrey@docker.com>
2014-10-02 17:37:13 +02:00
Konrad Kleine
e08f22cdb2 Typo: changed "Maintainers" to "maintainers"
Signed-off-by: Konrad Kleine <konrad.wilhelm.kleine@gmail.com>
2014-10-02 08:43:30 +02:00
Derek McGowan
7c88e8f13d Add provenance pull flow for official images
Add support for pulling signed images from a version 2 registry.
Only official images within the library namespace will be pull from the
new registry and check the build signature.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-01 18:26:06 -07:00
Ken Cochrane
7f261ebe6c Fixed issue with docs not getting built due to ssl error.
Signed-off-by: Ken Cochrane <ken@docker.com>
2014-10-01 21:11:10 -04:00
Jessie Frazelle
7304c09ecc Merge pull request #8346 from juliantaylor/mkimage-debootstrap
fix help message for mkimage debootstrap with components
2014-10-01 17:47:26 -07:00
Srini Brahmaroutu
ecff6303a3 Print a status message when pull command is executed
Using repo tag in the status message for better usability, as per review comments
Added documentation and Changed code to print Status after downloads are complete

Addresses #2404

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
2014-10-01 22:55:29 +00:00
Michael Crosby
4c8b8861ec Merge pull request #8350 from erikh/add_erikh_maintainer_proxy
Add erikh as maintainer of pkg/proxy
2014-10-01 15:50:41 -07:00
Erik Hollensbe
10efa07fa2 Add erikh as maintainer of pkg/proxy
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-10-01 15:37:46 -07:00
Fred Lifton
23221c5566 Merge pull request #8337 from tjwebb123/patch-1
Update host_integration.md
2014-10-01 15:37:02 -07:00
Julian Taylor
34672240b4 fix help message for mkimage debootstrap with components
debootstrap needs the suite as the second argument, for this the script
reorders arguments beginning with a minus but components separated by
space, as stated by the help message, is not handled and will lead to
the rootfs being passed as suite to debootstrap.
The poor mans solution is to fix the help message to pass the long
option as one argument.

Signed-off-by: Julian Taylor <jtaylor.debian@googlemail.com>
2014-10-01 23:18:23 +02:00
Derek McGowan
8a6c7100ea Update libtrust version
Updated to version of libtrust with the trust graph implementation

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-10-01 13:19:40 -07:00
Vincent Batts
61c6f206b0 registry: getting Endpoint ironned out
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-10-01 13:19:40 -07:00
Fred Lifton
04251b3e54 Merge pull request #8316 from duglin/Issue4787
Add a note about using an open schema model - Issue #4787
2014-10-01 11:21:09 -07:00
Doug Davis
c8f3151aa6 Add a note about using an open schema model
Closes: #4787

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-10-01 11:05:12 -07:00
Fred Lifton
f852233a01 Merge pull request #8313 from duglin/Issue4877
Add missing "tag" parameter to tag API - Issue #4877
2014-10-01 10:34:57 -07:00
Alexandr Morozov
516c72d71b Merge pull request #8340 from unclejack/bump_go_to_1.3.3
bump Go to 1.3.3
2014-10-01 08:08:12 -07:00
unclejack
4424d15f99 Merge pull request #8302 from rafecolton/move_archive_package_to_pkg
Move archive package to pkg
2014-10-01 18:03:34 +03:00
Adrien Folie
2c5b5cfc92 Add ENV variables support to WORKDIR build command
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Adrien Folie <folie.adrien@gmail.com> (github: folieadrien)

Conflicts:
	builder/builder.go
		This file has been deleted.
2014-10-01 17:34:36 +03:00
unclejack
da34672de6 bump Go to 1.3.3
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-10-01 17:14:48 +03:00
tjwebb123
f10a08887e Update host_integration.md 2014-10-01 14:51:47 +01:00
Konrad Kleine
12fe99ae47 Add registry_api_client_libraries.md to mkdocs.yml
Signed-off-by: Konrad Kleine <konrad.wilhelm.kleine@gmail.com>
2014-10-01 15:32:21 +02:00
Konrad Kleine
3446735a3e Create registry_api_client_libraries.md
Signed-off-by: Konrad Kleine <konrad.wilhelm.kleine@gmail.com>
2014-10-01 15:20:49 +02:00
Andrea Luzzardi
3f2e4e94d7 Merge pull request #8266 from cpuguy83/fix_race_in_createing_volumes
Fix potential race in volume creation
2014-09-30 18:03:00 -07:00
Andrea Luzzardi
d40ab6f123 Merge pull request #8299 from vieux/pr_7425
Add --security-opts options to allow user to customize container labels and apparmor profile
2014-09-30 17:53:11 -07:00
Fred Lifton
42b377904b Edits and fixes to Dockerfile Best Practices based on review feedback.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-30 13:30:14 -07:00
James Turnbull
5e69f4a188 Merge pull request #8291 from mieciu/master
Source the bash_completion after installation
2014-09-30 15:55:25 -04:00
James Turnbull
1d199f2d85 Merge pull request #8286 from ClusterHQ/8285-volume-api-docs
Document Volumes and Binds
2014-09-30 15:53:41 -04:00
Victor Vieux
08547dff29 update tests
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-30 19:10:03 +00:00
Michael Crosby
d4e5fa5728 Merge pull request #8092 from vishh/exec_api_docs
Exec remote API documentation
2014-09-30 11:50:23 -07:00
Vishnu Kannan
021ecb1d13 Adding exec remote API documentation along with minor code cleanup.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-30 18:26:58 +00:00
Victor Vieux
226bc669aa update docs
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-30 18:15:23 +00:00
Doug Davis
ee0b64f7a7 Add missing "tag" parameter to tag API
Closes #4877

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-30 10:53:29 -07:00
Alexandr Morozov
e32b54fe35 Merge pull request #8263 from jfrazelle/filter-status-name
Filter containers by status.
2014-09-30 10:40:02 -07:00
Davide Ceretti
17500eb188 Prettify docs-update.py
Remove commented code, use format for string concatenation, split long lines, fix how-to-run instructions
Signed-off-by: Davide Ceretti <dav.ceretti@gmail.com>
2014-09-30 17:00:15 +01:00
unclejack
1b6da6a6fe Merge pull request #8309 from ArikaChen/master
Fix typo:betweem->between and PtySlace->PtySlave
2014-09-30 16:20:31 +03:00
ArikaChen
bfc9d8bbea Fix typo:betweem->between and PtySlace->PtySlave
Signed-off-by: Arika Chen <eaglesora@gmail.com>
2014-09-30 07:22:09 -04:00
Rafe Colton
30d5a42c1f Move archive package into pkg/archive
Now that the archive package does not depend on any docker-specific
packages, only those in pkg and vendor, it can be safely moved into pkg.

Signed-off-by: Rafe Colton <rafael.colton@gmail.com>
2014-09-29 23:23:36 -07:00
Rafe Colton
73f4bfed81 Move Matches() file path matching function into pkg/fileutils
This is the second of two steps to break the archive package's
dependence on utils so that archive may be moved into pkg. `Matches()`
is also a good candidate pkg in that it is small, concise, and not
specific to docker internals

Signed-off-by: Rafe Colton <rafael.colton@gmail.com>
2014-09-29 23:21:41 -07:00
Rafe Colton
b845a62149 Move Go() promise-like func from utils to pkg/promise
This is the first of two steps to break the archive package's dependence
on utils so that archive may be moved into pkg.  Also, the `Go()`
function is small, concise, and not specific to the docker internals, so
it is a good candidate for pkg.

Signed-off-by: Rafe Colton <rafael.colton@gmail.com>
2014-09-29 23:16:27 -07:00
Jessica Frazelle
ea09f03682 Filter containers by status.
A continuation of #7616.
Adds `docker ps --filter=status=(restarting|running|paused|stopped)` option.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-29 20:11:19 -07:00
Fred Lifton
8128339bc8 Merge pull request #8281 from dfarrell07/master
Doc update to clarify EXPOSE vs -p functionality.
2014-09-29 18:55:11 -07:00
James Turnbull
4b311e1bd2 Merge pull request #8280 from duglin/Issue3636
Add more info about when build cache is invalidated/used - Issue #3636
2014-09-29 21:52:42 -04:00
Daniel Farrell
5730abc167 Doc update to clarify EXPOSE vs -p functionality.
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
2014-09-29 20:59:12 -04:00
unclejack
35005595b9 Merge pull request #8296 from scollier/typo
Fixed simple typo
2014-09-30 03:48:48 +03:00
Victor Vieux
c2c5e57a8e add apparmor:
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-30 00:43:47 +00:00
Tianon Gravi
07179a7eb1 Merge pull request #8293 from crosbymichael/update-libcontainer-sep8
Update libcontainer to c744f6470e37be5ce1f1ae09b842c15c1bee120d
2014-09-29 18:09:25 -06:00
Dan Walsh
87e732a0f3 Add --security-opts options to allow user to customize security configuration
security-opts will allow you to customise the security subsystem.

For example the labeling system like SELinux will run on a container.

    --security-opt="label:user:USER"   : Set the label user for the container
    --security-opt="label:role:ROLE"   : Set the label role for the container
    --security-opt="label:type:TYPE"   : Set the label type for the container
    --security-opt="label:level:LEVEL" : Set the label level for the container
    --security-opt="label:disabled"    : Turn off label confinement for the container

Since we are passing a list of string options instead of a space separated
string of options, I will change function calls to use InitLabels instead of
GenLabels.  Genlabels interface is Depracated.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-30 00:06:22 +00:00
Victor Vieux
595b5bf06e Merge pull request #8295 from crosbymichael/type-exec-context
Strongly type exec driver context
2014-09-29 17:02:53 -07:00
Scott Collier
35aa3fd5f2 Fixed simple typo
Signed-off-by: Scott Collier <emailscottcollier@gmail.com>
2014-09-29 18:58:47 -05:00
Victor Vieux
999d4117f6 Merge pull request #8112 from dmcgowan/libtrust_key_management
Libtrust key management
2014-09-29 16:32:48 -07:00
Michael Crosby
32dca1a7b0 Strongly type exec driver context
This also removes dead code in the native driver for a past feature that
was never fully implemented.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-29 22:40:26 +00:00
Victor Vieux
7c1aee6291 Merge pull request #8289 from duglin/FixTestcaseFor8230
Fixes the new testcase for PR #8230
2014-09-29 15:33:51 -07:00
Przemek Hejman
9f59e2223d Source the bash_completion after installation
Signed-off-by: Przemek Hejman <przemyslaw.hejman@gmail.com>
2014-09-29 23:37:51 +02:00
Michael Crosby
532c29ef7d Update native driver to set RootFs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-29 21:35:25 +00:00
Fred Lifton
a7d61e0ffb Merge pull request #8210 from dastergon/improve_gentoodoc
improve docs for Gentoo Linux installation
2014-09-29 14:35:21 -07:00
Michael Crosby
392eec2075 Update libcontainer to c744f6470e37be5ce1f1ae09b84
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-29 21:23:42 +00:00
Doug Davis
83f0f46b7c Add more info about when build cache is invalidated/used - Issue #3636
Plus some edits as suggested by @jamtur01

Closes #3636

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-29 14:13:39 -07:00
Pavlos Ratis
f90d201d88 improve docs for Gentoo Linux installation
Changes summary:
    * Added available USE flags table(description included).
    * Added some tips regarding the use of docker in the Gentoo environment.
    * Sorted out docker installation ways.
    * Added information about the newly created Gentoo Docker team.
    * Misc improvements

Signed-off-by: Pavlos Ratis <dastergon@gentoo.org>
2014-09-29 23:59:43 +03:00
Doug Davis
8b3fbac15c Fixes the new testcase for PR #8230
This new version makes sure that the same context is used for the two
builds run in the test.  If you don't use the same build then about 1/2 the
time the file copied into the container will look like a different file,
probably due to timestamp differences.  But reusing the same context we
re-use the same file on disk and therefore avoid the change in timestamps,
and we use the cache on the 2nd build.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-29 13:35:09 -07:00
Jessie Frazelle
826439c537 Merge pull request #8273 from duglin/Issue7941
Fix error paring null JSON - Issue7941
2014-09-29 12:59:34 -07:00
Tibor Vass
670c8696a2 Merge pull request #8284 from erikh/fix_cmd_again
builder: Fix CMD to inject /bin/sh -c when provided with a non-json value
2014-09-29 15:56:16 -04:00
Erik Hollensbe
9f142bf9be builder: Fix CMD to inject /bin/sh -c when provided with a non-json value.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-29 12:22:18 -07:00
Jean-Paul Calderone
8e70d553f9 Document Volumes and Binds
Signed-off-by: Jean-Paul Calderone <jean-paul@clusterhq.com>
2014-09-29 14:59:48 -04:00
Alexandr Morozov
6cd8602827 Merge pull request #8047 from rhatdan/RemoveLocalDns
Remove nameserver 127.0.0.1 line rather then dumping resolv.conf
2014-09-29 11:58:27 -07:00
Brian Goff
8d7c7bd2e3 Fix potential race in volume creation
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-29 14:56:04 -04:00
James Turnbull
2682393ce1 Merge pull request #8227 from SvenDowideit/list-container-events
The list of events that 'grep' told me about
2014-09-29 14:34:48 -04:00
James Turnbull
1dae56c893 Merge pull request #8245 from filbranden/patch-1
Update google.md to point to latest container-vm version
2014-09-29 14:30:24 -04:00
Erik Hollensbe
1cd6135972 Merge pull request #8230 from duglin/Issue6820
add wildcard support to COPY/ADD (part 2 of issue #6820)
2014-09-29 11:19:01 -07:00
Victor Vieux
22bd54be4a Merge pull request #8276 from dqminh/8262-validate-build-tag
Fix #8262: check tag's validity before building.
2014-09-29 10:57:54 -07:00
Michael Crosby
74dbea81d6 Merge pull request #8175 from hqhq/master
graph: add VirtualSize for inspect output
2014-09-29 10:50:28 -07:00
Vincent Batts
dab061bb64 Merge pull request #8282 from proppy/patch-10
api/server/MAINTAINERS: back from vacation
2014-09-29 13:12:06 -04:00
Johan Euphrosine
8019eec681 api/server/MAINTAINERS: back from vacation
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
2014-09-29 10:03:07 -07:00
Erik Hollensbe
27c5269b4e Merge pull request #8274 from tianon/parallel-shellshock
Move the body of go_compile_test_dir into a file since GNU Parallel breaks on sourcing exported Bash functions thanks to the shellshock fixes
2014-09-29 09:34:36 -07:00
James Turnbull
6fec88f0b3 Merge pull request #8246 from brahmaroutu/doc_resize_tty_7840
Documenting Container Tty resize api
2014-09-29 12:29:32 -04:00
James Turnbull
a9e31285b5 Merge pull request #8255 from rhatdan/execman
docker-exec man page is not created.
2014-09-29 12:20:14 -04:00
Dan Walsh
a297d6ab8c Replace utils.CheckLocalDns with bytes.Contains line
Since RemoveLocalDns patch will  remove all localhost entries
from resolv.conf we no longer need anything more then
!bytes.Contains(resolvConf, []byte("nameserver")

To check for no nameserver entry in dns config.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-29 06:37:31 -04:00
Dan Walsh
65640994fd Remove nameserver 127.0.0.1 line rather then dumping resolv.conf
We have a bug report complaining about docker dumping the contents of the
hosts resolv.conf if it container 127.0.0.1.  They asked that instead
of dropping the file altogether, that we just remove the line.

This patch removes the 127.0.0.1 lines, if they exist and then
checks if any nameserver lines exist.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-29 06:37:31 -04:00
Daniel, Dao Quang Minh
8833d800bf check tag's validity before building.
When user passes an invalid tag to `docker build`
(i.e.  `docker build -t abcd:A0123456789B0123456789C0123456789 .`), check the
tag first and terminate-early so user can specify the tag again

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
2014-09-29 06:21:54 -04:00
Tianon Gravi
8ffdf6022e Move the body of go_compile_test_dir into a file since GNU Parallel breaks on sourcing exported Bash functions thanks to the shellshock fixes
Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-09-28 21:51:44 -06:00
Doug Davis
a7cd25b8b6 Fix error paring null JSON - Issue7941
Closes #7941

Treat a null in JSON, when reading the config of a container, as if the
property was never included.  W/o this fix the null would be saved in the
property as a string with a value of "null".

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-28 19:51:00 -07:00
Michael Crosby
d142b18aab Merge pull request #8260 from cpuguy83/8259_fix_bindmount_symlink_reuse
Fix #8259 - Can't reuse symlink'd bindmount
2014-09-26 16:37:56 -07:00
Derek McGowan
ea6a480128 Add libtrust key identity management
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-09-26 15:52:08 -07:00
Derek McGowan
a049ac32d1 Vendor libtrust
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-09-26 15:48:12 -07:00
Brian Goff
882223c0f8 Fix #8259 - Can't reuse symlink'd bindmount
volumes.Get was not checking for symlinked paths meanwhile when adding a
new volume it was following the symlink.
So when trying to use a bind-mount that is a symlink, the volume is
added with the correct path, but when another container tries to use the
same volume it got a "Volume exists" error because volumes.Get returned
nil and as such attempted to create a new volume.

Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-26 14:36:44 -04:00
Michael Crosby
0bb5f98731 Merge pull request #8233 from tiborvass/pr-7658
Fix Interactive container hangs when redirecting stdout
2014-09-26 11:31:29 -07:00
Victor Vieux
bef8bad9d1 Merge pull request #8254 from unclejack/bump_go_to_1.3.2
bump Go to 1.3.2
2014-09-26 10:34:19 -07:00
Srini Brahmaroutu
c7f3fdc629 Documenting Container Tty resize api
Addresses #7840

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
2014-09-26 16:26:21 +00:00
Tibor Vass
07da2e03b1 Merge pull request #8224 from cpuguy83/7843_fix_start_attach_error_hang
Fix #7843 start -a can cause frozen term
2014-09-26 11:54:39 -04:00
Brian Goff
9ae9d7db57 Fix #7843
When doing `docker start -a` on a container that won't start, terminal
was getting stuck on the attach, even after container removal.

Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-26 11:31:02 -04:00
Dan Walsh
0a8fb80d99 docker-exec man page is not created.
docker-exec.md needs to be renamed in order to build man page.
Should be docker-exec.1.md

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-26 09:31:59 -04:00
unclejack
0f15221240 bump Go to 1.3.2
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-26 12:48:28 +03:00
James Turnbull
3151ecd7bb Merge pull request #8252 from SvenDowideit/sven-oct-2014-pto
comment out my MAINTAINER line: Gone Camping
2014-09-25 23:46:26 -07:00
Sven Dowideit
afacaba79b Gone Camping
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-26 14:28:39 +10:00
Doug Davis
acd40d5079 add wildcard support to copy/add
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-25 20:44:51 -07:00
SvenDowideit
71e28f9d64 Add the 2 image events found using git grep 'Job("log"'
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-26 11:55:36 +10:00
SvenDowideit
05060a7c94 The list of events that 'grep' told me about
docker(master) $ git grep 'LogEvent("' | sed 's/.*("//' | sed 's/").*//'
| sort | uniq | paste -s -d","
create,destroy,die,export,kill,pause,restart,start,stop,unpause

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-26 11:25:36 +10:00
Sven Dowideit
6df533adb4 Merge pull request #8209 from brahmaroutu/doc_dockerignore_7724
Adding details on how to use .dockerignore file
2014-09-26 10:53:36 +10:00
Victor Vieux
f721075283 Merge pull request #8237 from dmcgowan/tarsum_buffer_fix
tarsum: fix panic with dynamic buffer
2014-09-25 16:22:02 -07:00
Jessie Frazelle
0dfee56ca4 Merge pull request #8247 from aluzzardi/f-run-hostconfig
API: Provide the HostConfig during "run".
2014-09-25 16:09:55 -07:00
Derek McGowan
5cdf7f5077 pkg/tarsum: fix panic with dynamic buffer
When read is called on a tarsum with a two different read sizes, specifically the second call larger than the first, the dynamic buffer does not get reallocated causing a slice read error.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2014-09-25 15:58:35 -07:00
Victor Vieux
0913009ebe Merge pull request #8191 from vieux/improve_error_exec_lxc
Improve error for docker exec & LXC
2014-09-25 15:58:21 -07:00
Andrea Luzzardi
1df87b9506 API: Provide the HostConfig during "run".
Currently, the HostConfig is only passed from the CLI to Docker only
when issuing a docker create, but not when doing a docker run.

In the near future, in order to allocate ports at creation time rather
than start time, we will need to have the HostConfig readily available
at container creation.

This PR makes the client always pass the HostConfig when creating a
container (regardless of whether it's for a run or create).

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-09-25 15:24:38 -07:00
Filipe Brandenburger
7c22b3d599 Update google.md to point to latest container-vm version
In order to match the version listed here:
https://cloud.google.com/compute/docs/containers/container_vms#starting_a_bare_container-vm_instance
2014-09-25 15:19:59 -07:00
Jessie Frazelle
1d8c66347e Merge pull request #8241 from vbatts/vbatts-devmapper_version
devmapper: include the version in `info`
2014-09-25 14:53:43 -07:00
Erik Hollensbe
993033d67a Merge pull request #8239 from erikh/hack_options
hack: TIMEOUT (for controlling test timeout) and forwarding of BUILDFLAGS to binary/dynbinary.
2014-09-25 14:36:00 -07:00
Jessie Frazelle
1156314589 Merge pull request #8243 from vieux/not_not
not not -> not
2014-09-25 14:35:26 -07:00
Erik Hollensbe
aa129b356f hack: TIMEOUT (for controlling test timeout) and forwarding of
BUILDFLAGS to binary/dynbinary.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-25 14:25:43 -07:00
Victor Vieux
d19d800898 not not -> not
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-25 21:23:27 +00:00
Vincent Batts
5630d466b2 devmapper: include the version in info
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-25 15:51:02 -04:00
Srini Brahmaroutu
d7725ececa Adding details on how to use .dockerignore file
Addresses #7724

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
2014-09-25 12:48:17 -07:00
Tibor Vass
1379c6ec50 Merge pull request #8193 from jfrazelle/8141-pull-all-image-aliases-for-id
Pull all image aliases for id
2014-09-25 15:22:46 -04:00
Fred Lifton
d024a6a316 Merge pull request #8228 from SvenDowideit/latest-commandline-doc-changes
Updated output from the docker cli help
2014-09-25 12:03:10 -07:00
Tibor Vass
29a62ceefc Add DockerCli tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-25 20:58:43 +02:00
Vojtech Vitek (V-Teq)
d742c57f53 DockerCli: Check IsTerminal() for both STDIN and STDOUT
`docker events > /tmp/out` should not print control
characters to non-terminal STDOUT.

This addresses commit 26b4a4920a
without creating regression described in issue #6509.

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-09-25 20:58:24 +02:00
Victor Vieux
e2728d9892 Merge pull request #8235 from duglin/Issue2515
Add checks for app/json - issue #2515
2014-09-25 11:56:31 -07:00
Jessica Frazelle
7d74be162c Pull all image aliases for id. Closes #8141.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-25 11:48:49 -07:00
Victor Vieux
857b739e29 Merge pull request #8208 from estesp/7851-fix-hostname-fqdn
Provide full hostname with domainname to underlying container layer
2014-09-25 11:33:50 -07:00
Vojtech Vitek (V-Teq)
40c7b53791 Fix #6509: Interactive container hangs when redirecting stdout
Cli IsTerminal() SYS_IOCTL operation should be determined from STDIN,
not from STDOUT.

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-09-25 20:14:25 +02:00
Tibor Vass
d369612b41 Merge pull request #7994 from erikh/parser_fix_volume_parsing
builder: Fix handling of VOLUME command where multiple volumes are specified in a space delimited list.
2014-09-25 12:45:48 -04:00
Erik Hollensbe
a5ca549a18 builder: Fix handling of VOLUME command where multiple volumes are
specified in a space delimited list.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-25 09:44:19 -07:00
Doug Davis
e2b8d4bd4a Add checks for app/json - issue #2515
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-25 08:54:48 -07:00
Phil Estes
5239ba3d06 Provide full hostname with domainname to underlying container layer
Addresses #7851

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2014-09-25 09:23:39 -04:00
SvenDowideit
cb6b196ab4 Updated output from the docker cli help
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-25 16:07:55 +10:00
Sven Dowideit
4547b6d529 Merge pull request #8205 from sequenceiq/master
Fix code example formatting in best-practices article
2014-09-25 12:34:36 +10:00
Sven Dowideit
2431345639 Merge pull request #8212 from hugoduncan/patch-1
Fix quoting of TESTFLAGS in devenvironment.md
2014-09-25 12:34:12 +10:00
Tibor Vass
3fa0ed0142 Merge pull request #8195 from tiborvass/migrate-get.docker.io
Replace get.docker.io -> get.docker.com and test.docker.io -> test.docker.com
2014-09-24 19:06:09 -04:00
Tibor Vass
808257654a Replace get.docker.io -> get.docker.com and test.docker.io -> test.docker.com
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-24 18:53:27 -04:00
Victor Vieux
a936842208 Merge pull request #8207 from LK4D4/rewrite_more_fixtures_test
Rewrite more fixtures test to not use fixtures.
2014-09-24 15:07:03 -07:00
Andrea Luzzardi
4479d69d56 Merge pull request #8200 from aluzzardi/f-ipallocator-check-range
IPAllocator: Ensure the allocated IPs are within network range.
2014-09-24 14:29:39 -07:00
Andrea Luzzardi
a471eb4d93 IPAllocator: Ensure the allocated IPs are within network range.
Since it is possible to request a specific IP, IPAllocator has to verify
that the request is within boundaries.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-09-24 11:04:28 -07:00
unclejack
f2fad5c290 Merge pull request #8173 from crosbymichael/update-mem-limit
Update memory limit for container
2014-09-24 20:55:25 +03:00
Hugo Duncan
7aa88a4ff6 Fix quoting of TESTFLAGS in devenvironment.md
Copy and pasting the example should now work, rather than TESTFLAGS being silently ignored.
2014-09-24 13:30:39 -04:00
Victor Vieux
75ecfdd63c Merge pull request #8182 from LK4D4/logjson_benchmark
pkg/logjson benchmark and test
2014-09-24 10:00:22 -07:00
Alexandr Morozov
d302d92961 Rewrite TestContextTar tests to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-24 17:09:18 +04:00
Alexandr Morozov
51a56399f6 Rewrite TestBuildWithInaccessibleFilesInContext to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-24 17:09:14 +04:00
Alexandr Morozov
52cf331206 Rewrite TestBuildRm to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-24 13:15:55 +04:00
Lajos Papp
be4454c4f0 Fix code example formatting in best-practices article
Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com>
2014-09-24 10:45:56 +02:00
Alexandr Morozov
ab4738b49f Rewrite TestBuildHistory to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-24 12:38:48 +04:00
Alexandr Morozov
1625cbfc4c Rewrite TestBuildForceRm to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-24 12:29:27 +04:00
Fred Lifton
8dd11c7175 Merge pull request #8197 from fredlf/adding_official-repo-guidelines
Docs for Official Repo release
2014-09-23 20:55:07 -07:00
Fred Lifton
f68f5fd521 Merge pull request #8157 from SvenDowideit/sshd-pam-fix
Fix for user kicked off after login on some hosts
2014-09-23 20:42:27 -07:00
Fred Lifton
a1609a7324 Merge pull request #8178 from SvenDowideit/systemd-example-moved
That Systemd example URL isn't there anymore
2014-09-23 20:41:13 -07:00
Fred Lifton
950eccab4a Revisions and edits based on feedback.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-23 18:26:02 -07:00
Victor Vieux
827634d355 Merge pull request #7973 from LK4D4/persist_execdriver_dir
Persist execdriver dir
2014-09-23 16:01:03 -07:00
Fred Lifton
6747dfc803 Typo and formatting fixes. Copy edits.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-23 15:51:17 -07:00
Tibor Vass
b12f3a6cca Merge pull request #8192 from unclejack/lower_timeout_integ
integration: lower timeout for stop/restart tests
2014-09-23 18:46:58 -04:00
unclejack
6a5f09b752 integration: lower timeout for stop/restart tests
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-24 01:20:41 +03:00
Victor Vieux
81a643211b Merge pull request #8186 from duglin/ErrInCopyCache
Make sure COPY/ADD on dirs doesn't grab too many files
2014-09-23 15:16:57 -07:00
Tibor Vass
27567e5593 Merge pull request #8187 from erikh/builder_onbuild_output
builder: properly communicate onbuild trigger information during subsequent builds.
2014-09-23 18:04:59 -04:00
Victor Vieux
ab30e19b96 Improve error for docker exec & LXC
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-23 21:47:33 +00:00
Fred Lifton
d9fd5f6199 Adding new Dockerfile Best Practices doc, and links thereto.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-23 14:21:00 -07:00
Doug Davis
cd329d062b Make sure COPY/ADD on dirs doesn't grab too many files
Add check for / first - per LK4D4's comment.
Add a comment to explain why we're adding a /

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-23 14:16:00 -07:00
Erik Hollensbe
8edacc673a builder: properly communicate onbuild trigger information during
subsequent builds.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-23 13:55:51 -07:00
Victor Vieux
42ec80bec0 Merge pull request #8101 from jfrazelle/6974-correct-ct-json-stream
Change content-type for json stream to application/x-json-stream.
2014-09-23 11:24:31 -07:00
Tibor Vass
e3f1f0d354 Merge pull request #8170 from duglin/Issue7547
Allow user to change email/passwd via login - Issue 7547
2014-09-23 13:57:56 -04:00
Tibor Vass
5ce7ee61ef Merge pull request #8179 from erikh/parser_fix_cmd_null
Parser fix cmd null
2014-09-23 13:42:55 -04:00
Victor Vieux
f2bc723bc6 Merge pull request #8181 from rhatdan/selinux_btrfs
--selinux-enabled flag should be ignored on Disabled SELinux systems
2014-09-23 10:31:19 -07:00
Michael Crosby
437fa0650e Merge pull request #8165 from duglin/Issue7309
If the Rename during an image delete fails, just delete the original dir  - Issue #7309
2014-09-23 10:28:48 -07:00
Dan Walsh
9e2eb0f1cc --selinux-enabled flag should be ignored on Disabled SELinux systems
On Fedora and RHEL we ship selinux-enabled flag in the docker.service config,
but if people setup the /var/lib/docker as btrfs and disable SELinux,
we should not block the daemon from running.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-23 13:21:25 -04:00
Victor Vieux
7e461915a6 Merge pull request #8168 from LK4D4/rewrite_fixture_tests
Rewrite some tests to not use fixtures
2014-09-23 10:02:59 -07:00
Tibor Vass
5c110b63dd Merge pull request #8127 from estesp/8107-fix-wait-error-return
Fix container wait error message to match server template for returning ...
2014-09-23 12:03:39 -04:00
Alexandr Morozov
2add198a7a Test for jsonlog.WriteLog
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 19:19:25 +04:00
Alexandr Morozov
0c899cefdd Rewrite TestBuildAddWholeDirToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 18:58:32 +04:00
Alexandr Morozov
570f1153b9 Rewrite TestBuildAddEtcToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 18:58:28 +04:00
Tibor Vass
9941b03af1 Merge pull request #8172 from vbatts/vbatts-devmapper_fix_devicset_status_devices
devmapper: `docker info` devices hard coded
2014-09-23 10:28:31 -04:00
Alexandr Morozov
81c9927f8f Benchmark for jsonlog.WriteLog
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 18:24:18 +04:00
Alexandr Morozov
c58391bbd0 Rewrite TestBuildAddDirContentToExistDir to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:58 +04:00
Alexandr Morozov
2d802d7f23 Rewrite TestBuildAddDirContentToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:58 +04:00
Alexandr Morozov
139b6ed3aa Rewrite TestAddSingleFileToNonExistDir to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:58 +04:00
Alexandr Morozov
6bb44b6d74 Rewrite TestAddSingleFileToExistDir to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:58 +04:00
Alexandr Morozov
5e2ea69606 Rewrite TestAddSingleFileToWorkdir to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:58 +04:00
Alexandr Morozov
682fbe0134 Rewrite TestAddSingleFileToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:09 +04:00
Alexandr Morozov
3824ec62e8 Rewrite TestBuildSixtySteps to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-23 15:15:09 +04:00
Erik Hollensbe
d1613e1d59 builder: integration-cli test for the previous commit.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-22 23:18:46 -07:00
Erik Hollensbe
1e93639aed builder: Appropriately initialize the Cmd in runconfig.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-22 23:10:05 -07:00
Sven Dowideit
46319a5c33 That URL isn't there anymore
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-23 15:04:00 +10:00
Doug Davis
86a3a9a282 if the Rename during an image delete fails, just delete the original dir
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-22 18:47:20 -07:00
Tianon Gravi
3ea5a20776 Merge pull request #8094 from smerrill/feature/avoid-docker-start-woes
Try to avoid issues when the Docker daemon restarts or stops on RHEL/CentOS 6
2014-09-22 19:06:51 -06:00
Qiang Huang
ec000cbf30 graph: add VirtualSize for inspect output
Currently inspect output just shows Size info, and that usally be
very small and even 0 which is confusing.

Fixes #8016

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2014-09-23 08:42:32 +08:00
Sven Dowideit
513f5a358a Merge pull request #8156 from SvenDowideit/tedyoung-patch-1
Misc. fixes and formatting clean-up
2014-09-23 10:16:05 +10:00
Sven Dowideit
ab43ad7d5f Apply @tedyoung's changes to the entire set of API docs.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-23 10:09:49 +10:00
Ted M. Young
f304d4b190 Misc. fixes and formatting clean-up
Cleaned up and corrected some invalid "example responses".
Added some missing double-quotes for examples that resulted in invalid JSON.
Other general cleanup of stray characters and typos.

Docker-DCO-1.1-Signed-off-by: Ted M. Young <tedyoung@gmail.com> (github: SvenDowideit)
2014-09-23 10:09:49 +10:00
Victor Vieux
99caa68a46 Merge pull request #7564 from unclejack/integcli-add_utils
integration cli: add some utility functions and use them
2014-09-22 17:00:01 -07:00
Sven Dowideit
60f6b0299a Merge pull request #8123 from dcro/docs-clarifications
Updated the documentation to to clarify random port mapping when using -...
2014-09-23 09:57:19 +10:00
Michael Crosby
9b755412ab Update memory limit for container
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-22 21:41:14 +00:00
Vincent Batts
636e8561a8 devmapper: resizepool hardcodes files as well
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-22 17:03:31 -04:00
Vincent Batts
7e9ba22dc3 devmapper: docker info devices hard coded
If `--storage-opt dm.datadev=/dev/loop0 --storage-opt
dm.metadatadev=/dev/loop1 ` were provided, the information was not
reflected in the information output.

Closes: #7137

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-22 16:40:20 -04:00
Alexandr Morozov
4778d7d52d Merge pull request #8125 from somaopensource/8102-fix
Check whether net.ParseIP returned nil or not
2014-09-22 23:00:25 +04:00
Doug Davis
e315493b0c Allow user to change email/passwd via login
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-22 11:58:09 -07:00
Alexandr Morozov
652cd6a842 Test on execdriver dir behavior
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-22 22:49:21 +04:00
Alexandr Morozov
623ebf203b Persistent directory for container in execdriver
This is needed for persistent namespaces

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-22 22:48:26 +04:00
unclejack
06d0853682 Merge pull request #8169 from unclejack/avoid_attach_alloc
daemon/attach: avoid mem alloc for interface
2014-09-22 21:29:50 +03:00
unclejack
950bfe4193 daemon/attach: avoid mem alloc for interface
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 21:17:50 +03:00
Victor Vieux
350b1cf6ea Merge pull request #5956 from vbatts/vbatts-tarsum_hashes
tarsum: allow for generic hashes
2014-09-22 11:11:25 -07:00
unclejack
c6965e3e45 integcli: add & use dockerCmdWithTimeout & InDir
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 21:02:51 +03:00
Victor Vieux
28e308c25e Merge pull request #7942 from estesp/7747-stderr-stdout-bug
Fix gh#7747: filter bare newline output and log client pull to stdout
2014-09-22 10:53:34 -07:00
unclejack
5d1cb9d005 integcli: add util to fetch container status
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 20:34:57 +03:00
unclejack
97b50e0f29 integcli: consolidate cmd exit code processing
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 20:32:50 +03:00
Jessica Frazelle
10ab2089ce Change content-type for json stream to application/x-json-stream.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-22 10:29:56 -07:00
Tibor Vass
ac75835931 Merge pull request #8109 from unclejack/avoid_jsonlog_alloc
daemon/logs: avoid JSONLog struct alloc in loop
2014-09-22 12:53:31 -04:00
unclejack
c8f5c686a5 Merge pull request #8166 from unclejack/integcli_pull_scratch
integcli: pull scratch for pull test
2014-09-22 19:16:30 +03:00
unclejack
77d29847e2 integcli: pull scratch for pull test
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 19:03:19 +03:00
unclejack
d2c104c3a0 daemon/logs: lower allocations in loop
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 18:57:28 +03:00
unclejack
473bb5274c pkg/jsonlog: avoid JSONLog allocation in loop
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 18:57:28 +03:00
Tibor Vass
9c7d975614 Merge pull request #8159 from LK4D4/fix_goroutine_leak_in_logs
Fix goroutine leak in logs following
2014-09-22 11:16:48 -04:00
Alexandr Morozov
1df4255102 Merge pull request #8164 from unclejack/fix_utils_race
integcli: fix race in runCommandWithStdoutStderr
2014-09-22 19:14:40 +04:00
unclejack
c69896d8a0 integcli: fix race in runCommandWithStdoutStderr
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-22 17:53:12 +03:00
Tibor Vass
3c03506cc2 Merge pull request #8121 from bbinet/cleanup-hello-world-container
Automatically clean up hello-world container with --rm
2014-09-22 10:52:50 -04:00
unclejack
9fb34ae571 Merge pull request #6101 from LK4D4/ip_range_#4986
Implement allocating IPs from CIDR within bridge network
2014-09-22 17:09:16 +03:00
Alexandr Morozov
5ad82d3ea6 Merge pull request #8137 from jfrazelle/8135-event-log-die-start-fail
After container fails to start, log the event die.
2014-09-22 12:47:04 +04:00
Oh Jinkyun
c2dc4245f1 Check whether net.ParseIP returned nil or not
This is fix of #8102

Signed-off-by: Oh Jinkyun <tintypemolly@gmail.com>
2014-09-22 16:52:23 +09:00
Alexandr Morozov
a7ee201ee8 Close logs pipes and catch write errors
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-22 10:55:46 +04:00
Alexandr Morozov
fd3f2e175f Change unused WriteCloser to Writer
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-22 10:54:58 +04:00
Dan Cotora
a8775d2f9a Doc update to clarify random port mapping on docker run -P
Signed-off-by: Dan Cotora <d@bluevision.ro>
2014-09-22 08:39:09 +03:00
SvenDowideit
7faa43d707 Fix for user kicked off after login on some hosts
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-22 13:33:38 +10:00
Sven Dowideit
27226d47c1 Merge pull request #8124 from jyrkiput/patch-1
Fix detaching from attached container
2014-09-22 09:28:10 +10:00
Sven Dowideit
23fdbbfee4 Merge pull request #8151 from shazow/sort-exec-docs
Cleanup: Fixed cli docs' command header sorting
2014-09-22 09:21:38 +10:00
Andrey Petrov
c5805c8772 Cleanup: Fix cli docs: Sorted command headers.
Signed-off-by: Andrey Petrov <andrey.petrov@shazow.net>
2014-09-20 18:10:11 -07:00
Alexandr Morozov
e7a9662974 Merge pull request #7972 from cpuguy83/split_volumes_from_daemon
Split volumes out from daemon
2014-09-20 16:23:20 +04:00
Alexandr Morozov
f8c998c605 Merge pull request #8144 from crosbymichael/reduce-logging
This reduces the amount of logging in the integration tests
2014-09-20 11:17:03 +04:00
Michael Crosby
8a9e827216 This reduces the amount of logging in the integration tests
There were a new areas in the brige driver that did not need to have log
output.  Those were removed.  Also set the engine's logging to false
when running the integration tests.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-19 17:30:37 -07:00
Jessica Frazelle
d64d55eca8 After container fails to start, log the event die.
Fixes #8135.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-19 16:06:49 -07:00
Jessie Frazelle
11446d30f7 Merge pull request #8139 from aluzzardi/fix-drone-integration-goenv
Fix drone integration
2014-09-19 16:05:52 -07:00
Brian Goff
45407cf00a Split volumes out from daemon
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-19 17:47:47 -05:00
Andrea Luzzardi
07cedaab86 Drone Config: Disable integration-cli/docker_cli_exec_test as it breaks.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-09-19 15:40:48 -07:00
Andrea Luzzardi
72fe4c8daa Drone Config: Use AUTO_GOPATH instead of hacking around.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-09-19 15:20:35 -07:00
Jessie Frazelle
ba726d9148 Merge pull request #8129 from vbatts/vbatts-archive_comments
archive: adding comment to exported functions
2014-09-19 14:36:52 -07:00
Tianon Gravi
77193089d8 Merge pull request #8130 from aluzzardi/f-drone-integration
Add drone.io configuration
2014-09-19 14:59:40 -06:00
Tibor Vass
7fafe170cf Merge pull request #8133 from crosbymichael/update-libcontainer-sep7
Update libcontainer to 185328a42654f6dc9a41814e578
2014-09-19 14:58:51 -04:00
Michael Crosby
63c8b8bf30 Merge pull request #8131 from unclejack/fix_perm_detection
integcli: fix permission detection for aufs
2014-09-19 11:55:56 -07:00
Jessie Frazelle
a8e964ebb2 Merge pull request #8134 from LK4D4/prefix_naming_cli
Prefix naming integration-cli tests
2014-09-19 11:54:04 -07:00
Michael Crosby
c41bc79098 Merge pull request #8118 from tiborvass/merge-8031
FIX 6613:launch docker fail with space named drive (squashed commits from 8031)
2014-09-19 11:44:43 -07:00
Michael Crosby
2531fba389 Update libcontainer to 185328a42654f6dc9a41814e578
Mac address support to the netlink pkg.
Cgroup performance and memory issues.
Netlink refactoring.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-19 11:21:44 -07:00
Erik Hollensbe
41f2b3c6bc Merge pull request #8128 from bfirsh/two-level-cli-commands
Add support for multiple level CLI commands
2014-09-19 11:14:36 -07:00
Alexandr Morozov
2e2422b0eb Use prefix naming for rmi tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
cc54b77fce Use prefix naming for rm tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
1ddd013b19 Use prefix naming for restart tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
00b82fcab6 Use prefix naming for ps tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
6e8c9e7bee Use prefix naming for port tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
b6325907e9 Use prefix naming for links tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
27a27b7388 Use prefix naming for create tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:54 +04:00
Alexandr Morozov
66cd3640f1 Use prefix naming for build tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 22:11:50 +04:00
unclejack
1a0347ff1d integcli: fix permission detection for aufs
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-19 21:08:57 +03:00
Vincent Batts
0fe56ce1b9 archive: adding comment to exported functions
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-19 14:02:12 -04:00
Andrea Luzzardi
ed072ed71d Add drone.io configuration
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-09-19 11:00:28 -07:00
Alexandr Morozov
f312f784e1 Use prefix naming for attach tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 21:56:25 +04:00
Alexandr Morozov
3812a6a846 Use prefix naming for inspect tests
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 21:56:25 +04:00
Alexandr Morozov
9720078f9e Use prefix naming for events test
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 21:56:25 +04:00
Alexandr Morozov
aa536b27a7 Use prefix naming for docker_cli_run_test.go
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-19 21:56:24 +04:00
Ben Firshman
e1b968f198 Add support for multiple level CLI commands
E.g. "docker groups create" will attempt to call the function
CmdGroupsCreate

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
2014-09-19 10:43:50 -07:00
Phil Estes
be6bce6ab8 Fix container wait error message to match server template for returning 404
Addresses #8107

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2014-09-19 13:33:00 -04:00
Jyrki Puttonen
1d2a1598c5 Fix detaching from attached container
Text was copied from man-pages https://raw.githubusercontent.com/docker/docker/master/docs/man/docker-attach.1.md

Signed-off-by: Jyrki Puttonen <jyrkiput@gmail.com>
2014-09-19 19:34:05 +03:00
Guillaume Dufour
acea488eb6 FIX 6613:launch docker fail with space named drive
Signed-off-by: Guillaume Dufour <guillaume.duff@gmail.com>
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-19 12:07:53 -04:00
Erik Hollensbe
e91de29e08 Merge pull request #8076 from duglin/MultiCopyAdd
Add support for copy/add with multiple src files
2014-09-19 09:01:29 -07:00
Bruno Binet
d78936b418 Automatically clean up hello-world container with --rm
Signed-off-by: Bruno Binet <bruno.binet@gmail.com>
2014-09-19 12:22:39 +02:00
Sven Dowideit
39ed048aab Merge pull request #8091 from jfrazelle/exec-main-manpage
Add docker-exec to main manpage
2014-09-19 16:17:11 +10:00
James Turnbull
742eb7e001 Merge pull request #8116 from SvenDowideit/use-boot2docker-shellinit
boot2docker shellinit will set any and all env vars needed.
2014-09-19 00:46:15 -04:00
Doug Davis
05b8a1eb36 Add support for copy/add with multiple src files
Part one of solution for issue #6820

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-18 20:12:13 -07:00
Michael Crosby
72e9015591 Merge pull request #7694 from eyakubovich/master
Add an option to disable IP masquerading
2014-09-18 18:33:45 -07:00
Michael Crosby
d5537e0f03 Merge pull request #6950 from jfrazelle/6831-check-flag-centos6.5
Fix duplicate iptables rules
2014-09-18 17:51:15 -07:00
Sven Dowideit
82aa895c6d Merge pull request #8061 from SvenDowideit/document-image-tarball-format
Add a little description of the image tarball format.
2014-09-19 10:32:13 +10:00
Jessie Frazelle
031231b5ed Merge pull request #8111 from acroca/master
Grammar fix
2014-09-18 17:27:24 -07:00
Sven Dowideit
7797572249 boot2docker shellinit will set any and all env vars needed.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-19 10:20:12 +10:00
Albert Callarisa
4e11902d05 'an file' -> 'a file' grammar fix
Signed-off-by: Albert Callarisa Roca <albert@acroca.com>
2014-09-19 08:12:33 +08:00
Alexandr Morozov
e909bbccc3 Merge pull request #8115 from vishh/exec_panic_fix
Initialize execStore while restoring a container from checkpoint.
2014-09-19 02:22:51 +04:00
Jessica Frazelle
42dafe4bd8 test for panic on daemon restart
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-18 21:54:42 +00:00
Vishnu Kannan
003afaf1ce Initialize execStore while restoring a container from checkpoint.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-18 21:40:53 +00:00
Vincent Batts
4e9925d780 tarsum: allow for alternate block ciphers
Not breaking the default cipher and algorithm for calculating checksums,
but allow for using alternate block ciphers during the checksum
calculation.

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
2014-09-18 10:34:58 -04:00
Steven Merrill
640d2ef6f5 Try to avoid issues when the Docker daemon restarts.
This change will allow the Docker daemon's init script to wait up to 5
minutes before being forcibly terminated by the initscript. Many
non-trivial containers will take more than the default 3 seconds to
stop, which can result in containers whose rootfs is still mounted and
will not restart when the daemon starts up again, or worse, orphan
processes that are still running.

Signed-off-by: Steven Merrill <steven.merrill@gmail.com>
2014-09-18 08:21:00 -04:00
unclejack
db5edfb748 Merge pull request #8105 from LK4D4/build_test_little_fix
Little fixes in cli build tests
2014-09-18 10:32:10 +03:00
Alexandr Morozov
184fe67bbc Add Build prefix to Copy tests
Now we can do "-run TestBuild" to test all build-tests and "-run
TestBuildCopy" for test all copy-tests

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-18 09:09:10 +04:00
Alexandr Morozov
aa0449c813 Fix logDone message for TestCopySingleFileToExistDir
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-18 09:02:05 +04:00
Frederick F. Kautz IV
3bb12d390a Adding additional documentation for fixed-cidr networking
Docker-DCO-1.1-Signed-off-by: Frederick F. Kautz IV <fkautz@alumni.cmu.edu> (github: fkautz)

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-18 08:48:24 +04:00
Sven Dowideit
db9f8ba55c Add a little description of the image tarball format.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-18 10:40:55 +10:00
Sven Dowideit
e9b5acba4b Merge pull request #8081 from abh1nav/master
Update remote_api_client_libraries.md
2014-09-18 10:24:53 +10:00
Sven Dowideit
c7c78acf81 Merge pull request #8025 from davidpelaez-forks/docs-fix
Improved X-Registry-Auth content instructions
2014-09-18 09:54:25 +10:00
Michael Crosby
f8be5f586f Merge pull request #8097 from erikh/builder_maintainers
Add a new MAINTAINERS file for the builder.
2014-09-17 15:42:34 -07:00
Erik Hollensbe
1ff1befd12 Add a new MAINTAINERS file for the builder.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-17 15:36:04 -07:00
Michael Crosby
77d30e7112 Merge pull request #8041 from unclejack/lower_allocations_broadcastwriter
lower the number of allocations in broadcastwriter
2014-09-17 15:26:44 -07:00
Tibor Vass
12f522ac65 Merge pull request #8095 from jfrazelle/cp-parse-subcommand-rebase
Removed runconfig.ParseSubcommand
2014-09-17 18:04:28 -04:00
Oh Jinkyun
9aa71549d6 Removed runconfig.ParseSubcommand
Removed runconfig.ParseSubcommand, changed it to runconfig.Parse and editted related tests and modules

Signed-off-by: Oh Jinkyun <tintypemolly@gmail.com>
2014-09-17 14:38:22 -07:00
unclejack
458b019e62 Merge pull request #7889 from vbatts/vbatts-tarsum_name_collision
tarsum: name collision fix
2014-09-17 21:59:39 +03:00
Jessica Frazelle
fc75ade4f8 Add docker-exec to main manpage
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-17 11:46:49 -07:00
Vincent Batts
c5e6362c53 tarsum: name collision fix
If a tar were constructed with duplicate file names, then depending on
the order, it could result in same tarsum.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-17 14:37:46 -04:00
Alexandr Morozov
c171cf0cc3 Merge pull request #8088 from unclejack/integcli-keep_permissions
integcli: run inaccessible context test in tmpdir
2014-09-17 22:06:26 +04:00
unclejack
be924087eb integcli: run build tests in tmpdir
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 20:05:33 +03:00
Tibor Vass
8b97e2c287 Merge pull request #8084 from unclejack/improve_stdcopy
stdwriter: improve perf by avoiding buffer growth
2014-09-17 12:47:00 -04:00
Jessie Frazelle
129da8f842 Merge pull request #8085 from tianon/hack-install-location
Add "hack/install.sh" to the "PRs welcome" note in the end of the install script
2014-09-17 09:20:33 -07:00
unclejack
2f6b1d7f4e Merge pull request #6 from LK4D4/benchmark_for_8084
Benchmark for StdWriter.Write
2014-09-17 18:39:46 +03:00
Alexandr Morozov
55cac6c942 Benchmark for StdWriter.Write
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-09-17 19:24:07 +04:00
unclejack
277aa9c674 stdcopy: improve perf by avoiding buffer growth
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 18:06:17 +03:00
unclejack
1f03e60c2a move stdcopy to pkg/stdcopy
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 18:06:17 +03:00
Tianon Gravi
adb6910095 Add "hack/install.sh" to the "PRs welcome" note in the end of the install script
Also, simplified the output method by using `cat >&2 <<EOF ...` instead of multiple lines of `echo >&2 '...'`.

Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-09-17 08:09:39 -06:00
Tianon Gravi
459b403c2f Merge pull request #8083 from unclejack/install_apparmor
hack/install.sh: install apparmor when enabled
2014-09-17 08:05:29 -06:00
unclejack
9851e8c4c1 use custom marshalling for JSONLog
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 17:03:54 +03:00
Tianon Gravi
bcf7ca0731 Merge pull request #8080 from SvenDowideit/test-for-ext4-fs-kernel-options
It seems that we need these 2 options enabled for both aufs and devicema...
2014-09-17 08:01:20 -06:00
unclejack
9ae3134dc9 add the timeutils package
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 14:30:08 +03:00
unclejack
9619ce9dd1 hack/install.sh: install apparmor when enabled
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 12:13:31 +03:00
Abhinav Ajgaonkar
ad65930d0b Update remote_api_client_libraries.md
Ordering all clients alphabetically, by language.
Including all available languages in `page_keywords`.

Signed-off-by: Abhinav Ajgonkar <abhinav316@gmail.com>
2014-09-17 03:42:57 -04:00
Sven Dowideit
b7259dc6d4 It seems that we need these 2 options enabled for both aufs and devicemapper drivers when running on EXT4 - so test for them
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-17 17:03:58 +10:00
Tianon Gravi
41e625eb7c Merge pull request #8001 from jfrazelle/fix-key-for-test-release-ubuntu
use correct apt-key for test.docker.io/ubuntu
2014-09-17 00:06:57 -06:00
Fred Lifton
b03f506303 Merge pull request #8073 from ClusterHQ/7743-restart-policy-api-doc
Add some documentation for the RestartPolicy feature.
2014-09-16 20:06:55 -07:00
Eugene Yakubovich
4dc4d56db9 Add an option to disable IP masquerading
For the cases where --bip option is used it is sometimes best to disable
IP masquerading as the provided bridge IP range may be routable.

Signed-off-by: Eugene Yakubovich <eugene.yakubovich@coreos.com>
2014-09-16 20:00:15 -07:00
David Pelaez
8c2b170c6e Improved X-Registry-Auth content instructions
Hi,

this is a small contribution to fix some slightly unprecise information about the `X-Registry-Auth` header required to pull from private registries through the remote API. After a lot of trial and I error I managed to find that the documentation indications had this issues:

* Apparently single quotes cannot be used and double quotes (regular JSON) is required.
* Also the `auth` key must be passed even if empty or a 403 will result.
* It was not clear what the `serveraddress` had to be.

I added some small clarifications for anyone taking a look at the docs to keep them from the problems I've encountered. Hope this is helpful.

Thanks to all the contributors for bringing so much awesomeness to the linux world. :)

Signed-off-by: David Pelaez Tamayo <hello@davidpelaez.me>
2014-09-16 19:20:47 -05:00
Jessie Frazelle
f98a1f1f7d Merge pull request #8019 from thockin/add-host
Allow extra lines in /etc/hosts
2014-09-16 17:19:16 -07:00
Tim Hockin
68e48b65a6 Allow extra lines in /etc/hosts
This adds a --add-host host:ip flag which appends lines to /etc/hosts.  This is needed in places where you want the container to get a different name resolution than it would through DNS.  This was submitted before as #5525, closed, and now I am re-opening.  It has come up 2 or 3 times in the last couple days.

Signed-off-by: Tim Hockin <thockin@google.com>
2014-09-16 23:38:23 +00:00
Alexandr Morozov
ca39a3e36b Merge pull request #7110 from tiborvass/merge-6907
Docker create (rebase of 6907)
2014-09-17 03:23:50 +04:00
Tibor Vass
37b3b34afa Merge pull request #7989 from jlhawn/graphdriver_differ_refactor
Refactor use of graphdriver.Differ
2014-09-16 18:58:38 -04:00
Alexandr Morozov
ffbd8fe5b9 Merge pull request #8068 from jfrazelle/cleanup-various-fix-me-refs
Cleanup various fix me refs
2014-09-17 02:54:54 +04:00
Tibor Vass
e49c701092 Resolve conflicts with restart policies
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-16 18:40:25 -04:00
SvenDowideit
22eb3a3a50 add 'docker create' man page
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-16 18:40:25 -04:00
Tibor Vass
1ec283c3eb Add create to contrib/completion
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-16 18:40:25 -04:00
Tibor Vass
7c85cf5f39 docs fix
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-09-16 18:40:24 -04:00
Alexander Larsson
b0cb37fd3b integration-cli: Add docker create tests
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-09-16 18:40:24 -04:00
Alexander Larsson
3a90004f3c Add "docker create" support
This exposes the already existing "create container" operation.  It is
very similar to "docker run -d" except it doesn't actually start the
container, but just prepares it. It can then be manually started using
"docker start" at any point.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)

Conflicts:
	api/client/commands.go
	runconfig/parse.go
	server/container.go

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-09-16 18:40:24 -04:00
Tibor Vass
9c3eedae89 Merge pull request #8074 from unclejack/add_exec_help
add exec to the commands list
2014-09-16 18:17:08 -04:00
unclejack
fccb026221 add exec to the commands list
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 01:13:43 +03:00
Alexandr Morozov
ed957232a1 Merge pull request #8055 from cpuguy83/7792_fix_volume_mount_ordering
Fix #7792 - Order mounts
2014-09-17 02:13:35 +04:00
Josh Hawn
09ad65ebd5 graphdriver interface name change, typo fix
Signed-off-by: Josh Hawn <josh.hawn@docker.com>
2014-09-16 15:10:32 -07:00
Josh Hawn
dee6b481fe Refactor use of graphdriver.Differ
Some graphdrivers are Differs and type assertions are made
in various places throughout the project. Differ offers some
convenience in generating/applying diffs of filesystem layers
but for most graphdrivers another code path is taken.

This patch brings all of the logic related to filesystem
diffs in one place, and simplifies the implementation of some
common types like Image, Daemon, and Container.

Signed-off-by: Josh Hawn <josh.hawn@docker.com>
2014-09-16 15:10:32 -07:00
Alexandr Morozov
eb21197c6b Merge pull request #8035 from duglin/Issue7965
Add timeout to client - fix for #7965
2014-09-17 01:55:48 +04:00
Brian Goff
0a3211f131 Fix #7792 - Order mounts
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-16 14:51:06 -07:00
Jean-Paul Calderone
d758da386a Add some documentation for the RestartPolicy feature.
Signed-off-by: Jean-Paul Calderone <jean-paul@clusterhq.com>
2014-09-16 17:40:56 -04:00
Jessie Frazelle
51b26853ef Merge pull request #7976 from duglin/Issue7902
Fix for issue 7902 - add trailing zeros to timestamps so logs align
2014-09-16 13:55:03 -07:00
Tianon Gravi
3ff8d45b35 Merge pull request #8070 from jfrazelle/exec-autocompletions
Add exec to autocompletions
2014-09-16 14:07:42 -06:00
Jessica Frazelle
c9c004d700 Add exec to autocompletions
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-16 13:01:10 -07:00
Alexandr Morozov
00fd008170 Merge pull request #8062 from vishh/run_in_phase2
Add support for 'docker exec' - phase 2
2014-09-16 23:56:12 +04:00
Vincent Batts
0a6fd743ea Merge pull request #8063 from jlhawn/tarsum_empty_tar_archive
tarsum: correct close and finish reads
2014-09-16 15:41:28 -04:00
Vishnu Kannan
c786a8ee5e Adding docker exec support in CLI.
Fixed a bug in daemon that resulted in accessing of a closed pipe.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-16 19:24:25 +00:00
Tibor Vass
f88e2e8b99 Merge pull request #8054 from estesp/6830-fix-json-strings
Proper JSON handling of strings that could be represented as other types
2014-09-16 15:11:25 -04:00
Tibor Vass
28f09f0632 Merge pull request #8059 from estesp/8057-refactor-regexp-to-package-var
Refactor all pre-compiled regexp to package level vars
2014-09-16 15:04:23 -04:00
Phil Estes
1b0b1ec657 Proper JSON handling of strings that could be represented as other types
Addresses #6830

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2014-09-16 13:51:02 -04:00
Jessica Frazelle
23b2c39a40 Return errors in NewDaemonFromDirectory instead of calling Fatal
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-16 10:42:59 -07:00
Jessica Frazelle
67c254a60a DisableNetworkBidge doesn't need to be public anymore
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-16 10:37:50 -07:00
Doug Davis
cd7a5f5c09 Fix for issue 7902.
Use utils.RFC3339NanoFixed ("2006-01-02T15:04:05.000000000Z07:00")
instead of time.RFC3339Nano to format our log timestamps - this way
things are aligned, in particular the nano seconds are padded with zeros

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-16 10:28:37 -07:00
Phil Estes
4119c9d7d9 Refactor all pre-compiled regexp to package level vars
Addresses #8057

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2014-09-16 12:57:44 -04:00
Tibor Vass
23bb6513a0 Merge pull request #8026 from tonistiigi/validate-context-error-handling
Improve ValidateContextDirectory error handling.
2014-09-16 12:44:55 -04:00
Josh Hawn
bc956c6b79 Correct tarsum finish logic
Tarsum now correctly closes the internal TarWriter which appends
a block of 1024 zeros to the end of the returned archive.

Signed-off-by: Josh Hawn <josh.hawn@docker.com>
2014-09-16 09:34:21 -07:00
Tonis Tiigi
a8914293fb Improve ValidateContextDirectory error handling.
- Errors sent to the walker callback functions were ignored. This meant that
  one could get a panic when calling methods on a nil FileInfo object. For
  example when the file did not exists any more.

- Lstat calls inside walker callback are reduntant because walker already calls
  Lstat and passes the result to the callback.

- Error returned from filepath.Rel() can never be EACCES because it compares
  strings and does not care about actual files.

- If Matched() returns error then ValidateContextDirectory() must return error.
  Currently it still kept walking although the outcome was already known. 

- Function will now fail in case of unknown error(not EACCES nor ENOENT).
  Previous implementation did not make a clear decision about this (but 
  panicked because of the issues above).

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
2014-09-16 19:17:34 +03:00
unclejack
4da86f88a0 Merge pull request #5977 from vbatts/vbatts-tarsum_xattrs
tarsum: include xattr headers in to the checksum
2014-09-16 18:07:03 +03:00
James Turnbull
b645589071 Merge pull request #8056 from SvenDowideit/use-sudo-docker-everywhere
Consistently use 'sudo docker' in examples
2014-09-16 08:43:58 -04:00
James Turnbull
b040ba99d0 Merge pull request #8060 from SvenDowideit/missing-t-in-get-api-eg
Added missing 't' from the end of the /images/{{id}}/get eg.
2014-09-16 08:43:26 -04:00
Sven Dowideit
4352ea7b0a Added missing 't' from the end of the /images/{{id}}/get eg.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-16 15:27:44 +10:00
Tianon Gravi
0954fb32a4 Merge pull request #8013 from unclejack/fix_testimportdisplay
integ-cli: fix TestImportDisplay & add FileServer
2014-09-15 22:36:51 -06:00
Sven Dowideit
fc9a3b1c1b Consistently use 'sudo docker' in examples
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-16 11:49:05 +10:00
Fred Lifton
023241614e Merge pull request #8034 from michaljemala/patch-1
The default name of the bridge created is called 'docker0'.
2014-09-15 17:32:57 -07:00
Doug Davis
f013aa7f96 Add a timeout when trying to connect to the server, otherwise sometimes it just hangs
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-15 17:30:38 -07:00
Sven Dowideit
602dc6865b Merge pull request #8030 from SvenDowideit/add-help-if-selinux-is-out-of-date
Help new users if their SELinux is not-upgraded yet.
2014-09-16 10:19:29 +10:00
Sven Dowideit
a3f51da98a Help new users if their SELinux is not-upgraded yet.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-16 10:18:50 +10:00
Sven Dowideit
2f65ed0968 Merge pull request #8036 from unclejack/kernel_version_requirement
docs: change kernel version requirement
2014-09-16 10:14:02 +10:00
Sven Dowideit
62b86613e8 Merge pull request #8037 from unclejack/shrink_docs_images
docs: shrink images
2014-09-16 10:13:03 +10:00
Vishnu Kannan
39030382c4 Adding state to exec commands to prevent multiple starts of a single exec command.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 23:14:04 +00:00
Vishnu Kannan
bfebdfde78 Splitting the exec remote API into two separate APIs inorder to support resizing of tty sessions.
1. /container/<name>/exec - Creates a new exec command instance in the daemon and container '<name>'. Returns an unique ID for each exec command.
2. /exec/<name>/start - Starts an existing exec command instance. Removes the exec command from the daemon once it completes.

Adding /exec/<name>/resize to resize tty session of an exec command.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 22:56:47 +00:00
unclejack
9e5592d6a1 integ-cli: fix TestImportDisplay & add FileServer
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-16 01:54:21 +03:00
Tibor Vass
8b18a2da54 Merge pull request #8051 from jfrazelle/image-tag-can-be-one-letter-test-update
Update integration-cli tests to allow one-letter tag as valid
2014-09-15 18:25:59 -04:00
Jessica Frazelle
985fae256f Update integration-cli tests to allow one-letter tag as valid.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-15 15:17:50 -07:00
Jessie Frazelle
09982d0f97 Merge pull request #8049 from unclejack/fix_tag_validation
graph: validate tags properly & add unit tests
2014-09-15 14:32:02 -07:00
unclejack
ada883b198 graph: validate tags properly & add unit tests
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-16 00:13:54 +03:00
Fred Lifton
4b0bb71627 Merge pull request #8023 from nerab/patch-1
Append instead of replace file contents
2014-09-15 13:54:41 -07:00
Vincent Batts
0ecafb8a69 tarsum: version the addition of xattrs
Now that TarSum can be versioned, move the addition of xattr headers in
to the next version of TarSum

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-15 16:08:05 -04:00
Fred Lifton
c892423209 Merge pull request #8005 from SvenDowideit/document-sshd-env-vars
Document how to pass ENV vars to the user's shell
2014-09-15 12:44:56 -07:00
Fred Lifton
fd501d4b3a Merge pull request #8044 from brahmaroutu/container_copy_6107
Change the copy command Content-Type header to x-tar
2014-09-15 12:06:48 -07:00
Vincent Batts
448c8ecb0f tarsum: include xattr headers in to the checksum
this is to enhance the tarsum algorithm, but _MUST_ be done in lock step
with the same for docker-registry. (PR will be cited)

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
2014-09-15 15:05:01 -04:00
Alexandr Morozov
fbae71326c Merge pull request #8020 from erikh/rewrite_hosts_files
Links v2: Mutable network files
2014-09-15 23:03:30 +04:00
Srini Brahmaroutu
788e4acaa3 Change the copy command Content-Type header to x-tar
Addresses #6107

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
2014-09-15 10:45:06 -07:00
Vishnu Kannan
0029180f7f Removing 'exec' feature from the CLI until the docker daemon supports resizing of
tty sessions for exec'ed commands.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 17:06:07 +00:00
Vishnu Kannan
669561c2aa Address review comments.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 17:00:00 +00:00
Vishnu Kannan
d980589de6 Adding integration tests for docker exec feature.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:59:59 +00:00
Vishnu Kannan
e1818d2a69 Update cli.md to include 'docker exec' feature.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:59:05 +00:00
Vishnu Kannan
d130c10ab7 Fix bug in attach handling for docker exec. Add docs for 'docker exec' feature.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:59:05 +00:00
Vishnu Kannan
e1cf95b593 Import nsenter in docker.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:59:05 +00:00
Vishnu Kannan
985d579586 Adding 'exec' command to remote API and CLI.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:59:03 +00:00
Vishnu Kannan
5130fe5d38 Adding support for docker exec in daemon.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:57:52 +00:00
Vishnu Kannan
f3c767d798 Adding Exec method to native execdriver.
Modified Attach() method to support docker exec.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-15 16:57:52 +00:00
Alexandr Morozov
88a786d3c4 Merge pull request #8038 from unclejack/failed_build_context_cleanup
clean up the context when a build fails
2014-09-15 17:50:50 +04:00
unclejack
31c0039022 clean up the context when a build fails
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-15 16:01:23 +03:00
unclejack
a10a86d437 Merge pull request #7698 from tamsky/tune2fs_base_filesystem
use tune2fs to disable ext4 mount counts and mount intervals
2014-09-15 15:42:52 +03:00
unclejack
0619512582 docs: change kernel version requirement
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-15 15:15:55 +03:00
unclejack
90dcc7c840 docs: shrink images
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-15 14:46:29 +03:00
Michal Jemala
140229677a The default name of the bridge created is called 'docker0'. 2014-09-15 12:10:46 +01:00
unclejack
c751e1739d Merge pull request #8010 from LK4D4/fix_ps_s_hang_#7999
Fix ps -s hang
2014-09-15 13:54:29 +03:00
Sven Dowideit
0658be89d0 Merge pull request #8028 from SvenDowideit/ekristen-patch-1
HTTP Status 201 not 200
2014-09-15 11:00:05 +10:00
Erik Kristensen
c4db3b8075 HTTP Status 201 not 200
The http status should be 201 not 200.

Docker-DCO-1.1-Signed-off-by: Erik Kristensen <erik@erikkristensen.com> (github: SvenDowideit)
2014-09-15 10:58:45 +10:00
Sven Dowideit
0c5a7ad577 Merge pull request #8008 from dwgebler/master
fixes incorrect environment variable labeling in container linking guide
2014-09-15 10:51:38 +10:00
Nicholas E. Rabenau
81357e12e7 Append instead of replace file contents
I think the `DOCKER_OPTS` should be appended to `/etc/default/docker` and not replace the entire contents.
2014-09-13 22:26:40 +02:00
Erik Hollensbe
09b700288e Allow /etc/hosts and /etc/resolv.conf to be updated both outside and
inside the container.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-13 11:27:34 -07:00
Tibor Vass
23f490427f Merge pull request #7983 from vbatts/vbatts-tarsum_switch_names
tarsum: TarSum should be the interface
2014-09-12 17:01:35 -04:00
unclejack
da4dba2e8c Merge pull request #8014 from jfrazelle/8012-prevent-container-names-starting-dash
Ensure container names start with a-zA-Z0-9
2014-09-12 23:15:16 +03:00
Michael Crosby
63a1548688 Merge pull request #8004 from duglin/Issue6447
Fix parsing of proto/port - issue 6447
2014-09-12 12:00:57 -07:00
Doug Davis
658a9d0f47 Fix parsing of proto/port
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-12 11:39:14 -07:00
Michael Crosby
a96811272a Merge pull request #7934 from LK4D4/fix_double_allocation
Fix error propagation from userland-proxy
2014-09-12 11:39:10 -07:00
Jessica Frazelle
aa2af817be Ensure container names start with a-zA-Z0-9
Closes #8012.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-12 10:45:07 -07:00
Fred Lifton
64ecef59af Merge pull request #7986 from abh1nav/master
Update remote_api_client_libraries.md
2014-09-12 10:37:00 -07:00
Fred Lifton
1501adad29 Merge pull request #7987 from SvenDowideit/stop-hurting-blackrosezys-eyes
Yep, its been hurting my eyes too - and you've finally inspired me to fi...
2014-09-12 10:35:30 -07:00
James Turnbull
127f72d3ba Merge pull request #8011 from fsouza/fix-typo-remote-api
docs/reference/api: fix typo in docs
2014-09-12 13:26:24 -04:00
Francisco Souza
fe5b72e7bb docs/reference/api: fix typo in docs
Signed-off-by: Francisco Souza <f@souza.cc>
2014-09-12 13:57:43 -03:00
Alexandr Morozov
a612d85916 Merge pull request #8009 from unclejack/better_run_test_debug
integ-cli: better debug output for run & import
2014-09-12 18:38:46 +04:00
unclejack
3ec564bfda integ-cli: better debug output for run & import
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-12 16:51:21 +03:00
James Turnbull
b6b85a58fd Merge pull request #7998 from duglin/Issue5701
Add notes about single-quotes (for issue 5701)
2014-09-12 07:41:31 -04:00
David Gebler
78fe117076 Signed-off-by: David Gebler <davidgebler@gmail.com>
modified:   userguide/dockerlinks.md
    fixes incorrect environment variable labeling in container linking guide
2014-09-12 11:04:40 +01:00
Alexandr Morozov
41cbce8c00 Test for docker ps -s
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-12 11:45:50 +04:00
Alexandr Morozov
82bdd88e9c Use unlocked version of changes for GetImage
Fixes #7999

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-12 11:44:51 +04:00
Alexandr Morozov
555ce0cb54 Use defined variable
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-12 11:42:12 +04:00
Alexandr Morozov
41e9e93e27 Fix my own comments from #7927
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-12 10:05:07 +04:00
Erik Hollensbe
3b6a29b81a Fix an issue where already allocated ports would not trigger an error.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-12 09:51:14 +04:00
Tibor Vass
3109fc9537 Add Test for port allocation bug (port already in use by other programs than docker)
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-12 09:51:14 +04:00
Sven Dowideit
0517099a91 Document how to pass ENV vars to the user's shell
As this is a somewhat common question.

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-12 13:34:01 +10:00
Sven Dowideit
df8dbfa45d Override prettyPrint's colour choice (red) for strings in quotes.
I've moved the docs.css to last so it can tweak any existing css, and
then set that to the same grey colour used for 'normal' text.

While testing I found and fixed an over-zealous line wrap.

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-12 11:10:07 +10:00
Michael Crosby
32b5d145fa Merge pull request #7963 from jfrazelle/7845-remove-image-fail-dont-untag
Failing to remove an image, will not remove the image name/tag.
2014-09-11 18:06:18 -07:00
Sven Dowideit
990da301cf Merge pull request #7988 from markotibold/patch-1
Fixed a typo
2014-09-12 10:41:12 +10:00
Sven Dowideit
c0783dfceb Merge pull request #7991 from laktek/master
Fixed a typo in docs (outpu -> output).
2014-09-12 10:40:16 +10:00
Sven Dowideit
6941931daa Merge pull request #8000 from estesp/7985-networkport-doc-changes
Match docs to actual port range used in code.
2014-09-12 10:18:03 +10:00
Michael Crosby
d9c7c1a7da Merge pull request #7957 from bfirsh/consistent-help-messages
Consistent help messages
2014-09-11 15:25:28 -07:00
Jessica Frazelle
440eb7fee8 use correct apt-key for test.docker.io/ubuntu
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-11 15:22:36 -07:00
Michael Crosby
98e409172c Merge pull request #7996 from estesp/7943-validate-tagnames
Validate tag names similar to repository name validation; add tests
2014-09-11 15:19:50 -07:00
Jessie Frazelle
2d4e43b26b Merge pull request #7959 from crosbymichael/update-libcontainer-sep6
Update libcontainer to 84ad9386a0240acb7475429a835
2014-09-11 14:59:24 -07:00
Phil Estes
46eb4140c9 Validate tag names similar to repository name validation; add tests
Addresses #7943

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2014-09-11 17:52:36 -04:00
Phil Estes
d6f4b2ebb4 Match docs to actual port range used in code.
Addresses #7985

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2014-09-11 17:20:01 -04:00
Jessica Frazelle
b2efdc538d Removing an image that fails, also removes the image name/tag.
Fixes #7845 and #7801, and a real pain point I had :)

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-11 11:29:25 -07:00
Michael Crosby
ed7fb3bbda Merge pull request #7202 from timbot/add-registry-mirror-flag
Add daemon flag to specify public registry mirrors
2014-09-11 11:11:01 -07:00
Michael Crosby
08f1a91ccd Merge pull request #7806 from erikh/fix_cmd_handling_in_parser
Fix cmd and entrypoint handling in parser
2014-09-11 10:42:22 -07:00
Jessie Frazelle
e550fc532c Merge pull request #7984 from vbatts/vbatts-engine_env_comments
engine.Env: comments and tests for Get()
2014-09-11 10:19:58 -07:00
Doug Davis
b47a2fbdc5 Add notes about single-quotes
Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-11 10:19:07 -07:00
Erik Hollensbe
91bed43621 builder: Fix an error check being done at the wrong spot in run
dispatcher

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
576416c99a move entrypoint integration-cli test for blank entrypoint to separate function
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
92f885d7bd Do not populate path to prevent runconfig merge conflict; remove
autoConfig seeding of entrypoint.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
78a847a47a evaluator: ensure entrypoint stays blank if set blank while CMD is set.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
ac107995ae builder: Fix entrypoint and cmd semantics in evaluator. Test c/o @cnf
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
3a6d1228a8 builder: Fix a small bug that could improperly cache.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
6b322ad2d3 builder/parser: fix handling of empty strings as the only argument.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Erik Hollensbe
234f0e4f79 builder/parser/dumper: Handle newlines appropriately.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-11 06:00:24 -07:00
Lakshan Perera
7b1fdd6c04 Fixed a typo in docs (outpu -> output).
Signed-off-by: Lakshan Perera <lakshan@laktek.com>
2014-09-11 09:09:59 +00:00
Abhinav Ajgaonkar
c7310b6463 Update remote_api_client_libraries.md
Adding docker rust client lib.

Signed-off-by: Abhinav Ajgonkar <abhinav316@gmail.com>
2014-09-11 03:04:35 -04:00
Marko Tibold
ef3920278e Fixed typo 2014-09-11 08:55:45 +02:00
Vincent Batts
6e0bc06018 engine.Env: comments and tests for Get()
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-10 22:20:49 -04:00
Vincent Batts
ec01eb653d tarsum: TarSum is not the interface
don't export the exsisting TarSum struct and call the interface 'TarSum'
instead.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-10 21:56:20 -04:00
Sven Dowideit
2d1c8bd786 Merge pull request #7975 from passy/patch-2
Fix link for configuring automated builds
2014-09-11 09:16:41 +10:00
Michael Crosby
48fe9c1082 Merge pull request #7689 from vbatts/vbatts-tarsum_versioning
TarSum: versioning
2014-09-10 15:08:36 -07:00
Fred Lifton
dd5657ffd1 Merge branch 'adding_official-repo-guidelines' of https://github.com/fredlf/docker into adding_official-repo-guidelines
Conflicts:
	docs/sources/docker-hub/official_repos.md

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-10 14:30:19 -07:00
Fred Lifton
a2ba4d56eb Fixes a couple small typos
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-10 14:26:03 -07:00
Fred Lifton
0164cf0e9c Merge pull request #1 from yosifkit/adding_official-repo-guidelines
Fix formatting, change to markdown block for long
2014-09-10 14:25:36 -07:00
Joe Ferguson
bcb9378c5b Fix formatting, change to markdown block for long
Signed-off-by: Joe Ferguson <joe@infosiftr.com>
2014-09-10 14:46:11 -06:00
Vincent Batts
747f89cd32 TarSum: versioning
This introduces Versions for TarSum checksums.
Fixes: https://github.com/docker/docker/issues/7526

It preserves current functionality and abstracts the interface for
future flexibility of hashing algorithms. As a POC, the VersionDev
Tarsum does not include the mtime in the checksum calculation, and would
solve https://github.com/docker/docker/issues/7387 though this is not a
settled Version is subject to change until a version number is assigned.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-10 15:41:52 -04:00
Pascal Hartig
ecbc8de249 Fix link for configuring automated builds 2014-09-10 21:08:05 +02:00
Michael Crosby
25f7840993 Merge pull request #7955 from LK4D4/ignore_delete_err_on_unmap_#7954
Deallocate port before trying to delete iptables chain
2014-09-09 17:41:26 -07:00
Michael Crosby
f9c345ddfa Merge pull request #7897 from LK4D4/refactoring_net_mode
Add IsPrivate method for NetworkMode
2014-09-09 14:20:59 -07:00
Alexandr Morozov
080ca86191 Add IsPrivate method for NetworkMode
This method indicates that container using private network stack

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-10 00:46:43 +04:00
Alexandr Morozov
2e7cf6b0ce Deallocate port before trying to delete iptables chain
Fixes #7954
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-10 00:40:46 +04:00
Vincent Batts
197f9b1e2b Merge pull request #7921 from unclejack/increase_tarsum_buffer_size
pkg/tarsum: make buffer size dynamic
2014-09-09 16:10:02 -04:00
Tim Smith
69a75c673c Add daemon flag to specify public registry mirrors
Adds support for a --registry-mirror=scheme://<host>[:port]
daemon flag. The flag may be present multiple times. If
provided, mirrors are prepended to the list of endpoints used
for image pull. Note that only mirrors of the public
index.docker.io registry are supported, and image/tag resolution
is still performed via the official index.

Docker-DCO-1.1-Signed-off-by: Tim Smith <timbot@google.com> (github: timbot)
2014-09-09 19:03:38 +00:00
Michael Crosby
b5a4c70455 Merge pull request #7960 from vbatts/vbatts-tarsum_debugf_not_infof
tarsum: use Debugf, not Infof
2014-09-09 11:51:36 -07:00
Jessie Frazelle
2a832f617b Merge pull request #7948 from SvenDowideit/add-more-port-specification-doc
add -p PORT as a valid format specification
2014-09-09 11:43:25 -07:00
Jessie Frazelle
971240696f Merge pull request #7660 from rhatdan/selinux-volumes
Change default label of container volumes to shared SELinux Label
2014-09-09 11:16:19 -07:00
Vincent Batts
6a8cae3e03 tarsum: use Debugf, not Infof
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-09-09 14:07:20 -04:00
Michael Crosby
c604dc292e Update libcontainer to 84ad9386a0240acb7475429a835
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-09 11:05:58 -07:00
Jessie Frazelle
49c32189c0 Merge pull request #7958 from dqminh/fix-lxc-template-console
fix console attribute in lxc template
2014-09-09 11:00:48 -07:00
Daniel, Dao Quang Minh
4b3b54ca38 fix console attribute in lxc template
commit 4aa5da278f moves `Console` from Command to
ProcessConfig, but missed the change in lxc_template. Therefore creating a
container with tty using lxc driver with fail with error

template: lxc:60:20: executing "lxc" at <.Console>: Console is not a field of
struct type struct { *execdriver.Command; AppArmor bool; ProcessLabel string; MountLabel string }

This changes lxc_console template to refers to `.ProcessConfig.Console`

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
2014-09-09 13:51:13 -04:00
Ben Firshman
fec81690cc Consolidate documentation for -H option
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
2014-09-09 10:12:03 -07:00
James Turnbull
1ed467a9ae Merge pull request #7953 from SvenDowideit/reformat-api-docs
Reformat the API docs so I can read them
2014-09-09 12:52:26 -04:00
Jessie Frazelle
17314e2fe8 Merge pull request #7951 from taohu/typo
typo fix: immediatly -> immediately
2014-09-09 09:44:51 -07:00
Dan Walsh
73617e5e18 Change default label of container volumes to shared SELinux Label
Since these will be shared between containers we want to label
them as svirt_sandbox_file_t:s0.  That will allow multiple containers
to write to them.

Currently we are allowing container domains to read/write all content in
/var/lib/docker because of container volumes.  This is a big security hole
in our SELinux story.

This patch will allow us to tighten up the security of docker containers.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-09-09 08:18:20 -04:00
Sven Dowideit
f36dfbdcaf Reformat the API docs so I can read them
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-09 16:17:38 +10:00
Hu Tao
fcc7ec8073 typo fix: immediatly -> immediately
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-09-09 01:16:19 -04:00
Fred Lifton
f1095b801e Merge pull request #7949 from SvenDowideit/remove-doubled-up-page-heading
Make the side bar about in-document navigation by removing the duplicated h1
2014-09-08 20:50:06 -07:00
Sven Dowideit
1f25bfea2d Make the side bar about in-document navigation by removing the duplicated h1
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-09 11:44:51 +10:00
Sven Dowideit
e4d2a8231a add -p PORT as a valid format specification
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-09 11:16:02 +10:00
Fred Lifton
5b6c4051d5 More format wrestling.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-08 17:32:29 -07:00
Fred Lifton
5fea2b5be3 More format fixes.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-08 16:30:39 -07:00
Ben Firshman
d128d9e669 Add instructions on how to get help on commands
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
2014-09-08 16:09:16 -07:00
Ben Firshman
f3ed7b601f Print consistent help with options and commands
These commands now all output the same thing:

 - docker
 - docker help
 - docker --help
 - docker -h

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
2014-09-08 16:08:50 -07:00
Fred Lifton
bb8ea1fdc1 Merge pull request #7931 from jamtur01/device
Added --device flag to run reference
2014-09-08 14:33:56 -07:00
Fred Lifton
577066fb45 Merge pull request #7930 from jamtur01/nformat
Very minor formatting update for docs/sources/articles/networking.md
2014-09-08 14:28:29 -07:00
Fred Lifton
10e4ca760c Merge pull request #7929 from SvenDowideit/doc-tar-stream
Sven Dowideit 	Update export, copy and build API to say 'TAR STREAM' for all versions.
2014-09-08 14:27:45 -07:00
Michael Crosby
85314e7e58 Merge pull request #7759 from unclejack/pull_latest_by_default
make docker pull only the latest tag by default
2014-09-08 13:43:21 -07:00
Fred Lifton
a899b8a63e Format and typo fixes
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-08 12:36:52 -07:00
Tibor Vass
d7e29a2cc8 Merge pull request #7891 from tlipinski/master
Allows installation on Linux Mint Debian Edition
2014-09-08 14:44:07 -04:00
Fred Lifton
eb8d0c1ccf Revisions based on feedback.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-08 11:43:09 -07:00
Jessie Frazelle
7bb5ec3be6 Merge pull request #7862 from Gandi/bugfixes/segfault-registry-session
Fix SEGFAULT if dns resolv error
2014-09-08 11:38:34 -07:00
Tomasz Lipinski
021722cf7a Allows installation on Linux Mint Debian Edition
Otherwise platform won't be detected

Signed-off-by: Tomasz Lipinski <me@tlipinski.net>
2014-09-08 20:38:02 +02:00
Jessie Frazelle
f7429a2121 Merge pull request #7871 from vincentbernat/update/zsh-completion-1
zsh: update zsh completion for docker command
2014-09-08 11:25:55 -07:00
Tibor Vass
43eab4034b Merge pull request #7938 from unclejack/make_run_test_verbose
integ-cli: increase verbosity for mem & cpu test
2014-09-08 14:10:58 -04:00
Michael Crosby
18edea2a6f Merge pull request #7609 from ewindisch/max_imgname
Restrict length of repository names
2014-09-08 11:06:54 -07:00
Michael Crosby
11700512b9 Merge pull request #7920 from unclejack/fix_layer_permissions
ensure correct permissions are set for directories
2014-09-08 10:51:50 -07:00
unclejack
05a76477e6 integ-cli: increase verbosity for mem & cpu test
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-08 20:46:45 +03:00
unclejack
cc5fb986b0 integ-cli: test correct directory permissions
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-08 20:02:40 +03:00
Alexandr Morozov
2360d4a440 Merge pull request #7886 from jfrazelle/7047-json-line-delim
Fix line delimited JSON response
2014-09-08 20:47:21 +04:00
Jessica Frazelle
d2f75a3040 Fix line delimited JSON response
For GET /events, line delimit JSON.
Fixes #7047

Signed-off-by: Jessica Frazelle <jfrazelle@users.noreply.github.com>

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jfrazelle@users.noreply.github.com> (github: )
2014-09-08 09:41:26 -07:00
Tibor Vass
68e07f3fa0 Merge pull request #7914 from jfrazelle/7802-backwards-compat-state
fixes #7802, when api version 1.11 is `json.Marshal`ing the container st...
2014-09-08 12:39:55 -04:00
Tianon Gravi
60ab9eaf4a Merge pull request #7868 from baloo/patch-1
Switch TESTFLAGS to use `-test.run` instead of `-run`
2014-09-08 10:34:49 -06:00
Jessica Frazelle
f49c3f287b fixes #7802, when api version 1.11 is json.Marshaling the container struct
Signed-off-by: Jessica Frazelle <jfrazelle@users.noreply.github.com>

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jfrazelle@users.noreply.github.com> (github: )
2014-09-08 09:30:33 -07:00
Leszek Kowalski
691bbf6a29 Include directories that contain changes inside them when calculating diff. Fixes #6722
Docker-DCO-1.1-Signed-off-by: Leszek Kowalski <github@leszekkowalski.pl> (github: ljk)
2014-09-08 19:11:48 +03:00
James Turnbull
8f0034c3ee Merge pull request #7933 from ahmetalpbalkan/doc-remote_api_client_libraries.md
add C# docker client library link to remote API client libraries doc
2014-09-08 07:25:24 -04:00
Ahmet Alp Balkan
cde53c51b5 add C# docker client library link
Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2014-09-07 23:29:04 -07:00
James Turnbull
9e34c42d20 Added --device flag to run reference
Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
2014-09-07 23:17:14 -04:00
James Turnbull
1ce3e22efc Very minor formatting update for docs/sources/articles/networking.md
Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
2014-09-07 22:39:37 -04:00
Sven Dowideit
77fa306d63 Update export, copy and build API to sat 'TAR STREAM' for all versions.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-08 11:54:21 +10:00
Mustafa Akın
b9e889c309 Update docker_remote_api_v1.14.md
It is a tar stream, you should mention that somehow.

Here is the proof:

```
	host:~$ docker run -t -i ubuntu:14.04 bash
	root@c39be4c7b7c8:/# echo "my file contents" > abc
	root@c39be4c7b7c8:/# cat abc
	my file contents
	root@c39be4c7b7c8:/# exit
	host:~$ curl -H "Content-Type: application/json" -d '{"Resource":"/abc"}' http://localhost:4500/containers/c39be4c7b7c8/copy
	abc0100644000000000000000000000002112402102531007674 0ustar0000000000000000my file contents
	host:~$ curl -H "Content-Type: application/json" -d '{"Resource":"/abc"}' http://localhost:4500/containers/c39be4c7b7c8/copy > response_content
	  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
	                                 Dload  Upload   Total   Spent    Left  Speed
	100  2067  100  2048  100    19  56968    528 --:--:-- --:--:-- --:--:-- 58514
	host:~$ tar xvf response_content
	abc
	host:~$ cat abc
	my file contents
```

Docker-DCO-1.1-Signed-off-by: Mustafa Akın <mustafa91@gmail.com> (github: SvenDowideit)
2014-09-08 11:52:27 +10:00
Sven Dowideit
4b3ee6c106 Merge pull request #7908 from nhsiehgit/issue363imgfix
added a css fix for the image bug issue
2014-09-08 11:10:03 +10:00
Jessica Frazelle
f3a68ffa39 Fix duplicate iptables rules
If iptables version is < 1.4.11, try to delete the rule vs. checking if it exists. Fixes #6831.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jfrazelle@users.noreply.github.com> (github: jfrazelle)
2014-09-07 15:12:19 -07:00
unclejack
7ef3440750 pkg/tarsum: add dynamic buffer sizing
This commit makes tarsum buffer allocation dynamic. This change
is required to avoid allocating memory excessively after the archive
buffering changes.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-06 17:39:43 +03:00
Phil Estes
b5184d3c24 Fix gh#7747 - filter bare newline output and log client pull to stdout
Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2014-09-06 01:06:18 -04:00
Marc Tamsky
d229821501 use tune2fs to disable ext4 mount counts and mount intervals
Signed-off-by: Marc Tamsky <mtamsky@gmail.com> (github: tamsky)
2014-09-05 19:32:39 -07:00
Nathan Hsieh
e44bdd612b added a css fix for the image bug issue
Docker-DCO-1.1-Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>
(github: nhsiehgit)
2014-09-05 10:48:51 -07:00
Tianon Gravi
38186084b3 Merge pull request #7893 from tianon/travis-run-tests
Update Travis to also run the test suite
2014-09-05 09:19:38 -06:00
James Turnbull
712702aa79 Merge pull request #7894 from SvenDowideit/use-local-jquery
Use a local copy of jquery so that the docs work in China, and offline too.
2014-09-05 08:51:09 -04:00
Arthur Gautier
3e6c69e5a1 Fix SEGFAULT if dns resolv error
Per registry.doRequest, res and client might be nil in case of error
For example, dns resolution errors, /etc/docker/certs.d perms, failed
loading of x509 cert ...
This will make res.StatusCode and res.Body SEGFAULT.

Signed-off-by: Arthur Gautier <baloo@gandi.net>
2014-09-05 13:40:06 +02:00
Sven Dowideit
5fe94f0d91 Use a local copy of jquery so that the docs work in China, and offline too.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-05 11:48:34 +10:00
Fred Lifton
58e8987837 Adding first draft of Official Repo Guidelines
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-04 18:09:00 -07:00
Victor Vieux
b0cff06c97 Merge pull request #7883 from LK4D4/fix_build_race
Fix race between dispatchers.run and toDisk
2014-09-04 17:32:46 -07:00
Sven Dowideit
03fdc7d2c1 Merge pull request #7890 from fredlf/docs-cherry-pick-update-process
Changes to Sven's cherry pick process
2014-09-05 09:58:18 +10:00
Tianon Gravi
068b9ac4d2 Update Travis to also run the test suite
Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-09-04 17:20:02 -06:00
Tibor Vass
1a2a4f61ab Merge pull request #7878 from LK4D4/fix_net_for_none
Don't initialize network for 'none' mode
2014-09-04 15:30:03 -07:00
Tianon Gravi
d3b5bf5d24 Merge pull request #7763 from jamtur01/kate
Add syntax highlighting file for KDE's "Kate" editor
2014-09-04 15:28:11 -06:00
Fred Lifton
b23daef3ec Changes to Sven's cherry pick process
Added content and revised after walk-through

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-04 13:32:16 -07:00
James Turnbull
f7c0ac9a8b Merge pull request #7873 from jankeromnes/patch-1
Update SSH demo to ubuntu 14.04
2014-09-04 15:45:55 -04:00
Jan Keromnes
98f57d1c39 Update SSH demo to ubuntu 14.04
Signed-off-by: Jan Keromnes <janx@linux.com>
2014-09-04 20:27:41 +02:00
James Turnbull
bc26aa7b50 Merge pull request #7876 from nhsiehgit/typofix
small typo. wrapping cut code snippet
2014-09-04 12:37:07 -04:00
Alexandr Morozov
f17410da5e Fix race between dispatchers.run and toDisk
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-04 19:43:28 +04:00
Alexandr Morozov
ba24820284 Don't initialize network for 'none' mode
Fixes #7837

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-04 09:50:58 +04:00
Sven Dowideit
dbe1123607 Merge pull request #7828 from vieux/update_api_docs
Remote api docs for POST /containers/create were out of sync with runconfig/config.go
2014-09-04 13:05:06 +10:00
Sven Dowideit
e1907bafb7 Merge pull request #7858 from somaopensource/typo-fix
Dockerfile documentation typo and content fix
2014-09-04 13:03:04 +10:00
Michael Crosby
d9fc61066d Merge pull request #7864 from unclejack/fix_panic_registry_session
registry/session: fix panic in GetRemoteImageLayer
2014-09-03 18:17:03 -07:00
Nathan Hsieh
adc9a14db4 small typo. fixed broken code snippet
Docker-DCO-1.1-Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com> (github: nhsiehgit)
2014-09-03 17:53:45 -07:00
Victor Vieux
68c256cd40 Merge pull request #7875 from tiborvass/fix-integration-panic
Fix panic in integration-cli
2014-09-03 17:33:04 -07:00
Tibor Vass
39310448da handle empty envvars for DOCKER_GRAPHDRIVER and DOCKER_EXECDRIVER in daemon test framework
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-03 17:14:19 -07:00
Tibor Vass
defe01daf8 fix race in daemon test framework
Signed-off-by: Tibor Vass <teabee89@gmail.com>
2014-09-03 17:14:19 -07:00
Victor Vieux
affef9e785 Merge pull request #7865 from cure/master
fix typos in error messages
2014-09-03 16:03:20 -07:00
Tibor Vass
782cde2c0f Merge pull request #7818 from thomasleveil/completion-docker-build
Add --force-rm to docker build command completion
2014-09-03 14:44:13 -07:00
James Turnbull
a3326c3469 Merge pull request #7850 from fredlf/add_cherrypick_process
Add cherrypick process
2014-09-03 17:33:49 -04:00
Vincent Bernat
dc2eab2cf4 zsh: update zsh completion for docker command
zsh completion is updated with the content of
felixr/docker-zsh-completion.

The major change since the last merge is the removal of use of
sed/awk. This should help a lot OSX users who previously had to install
gawk and gsed.

Docker-DCO-1.1-Signed-off-by: Vincent Bernat <vincent@bernat.im> (github: vincentbernat)
2014-09-03 22:30:11 +02:00
Ward Vandewege
a447894946 fix typos in error messages
Signed-off-by: Ward Vandewege <ward@jhvc.com> (github: cure)
2014-09-03 13:12:10 -04:00
Arthur Gautier
2a7770a712 The correct option for go test is -test.run not -run 2014-09-03 19:06:25 +02:00
unclejack
6ba5d67a51 docker build: pull just latest if tag uspecified
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 18:32:47 +03:00
SvenDowideit
82b0c3e59c add a little documentation for docker pull
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-09-03 18:32:41 +03:00
unclejack
9c08364a41 add --all-tags to pull & pull latest by default
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 18:03:14 +03:00
unclejack
9c413e3e6f registry/session: fix panic in GetRemoteImageLayer
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 17:26:56 +03:00
Thomas LÉVEIL
40f0bf7564 Add --force-rm to docker build command completion
Signed-off-by: Thomas LEVEIL <thomasleveil@gmail.com>
2014-09-03 14:26:16 +02:00
Oh Jinkyun
476f1df36f Dockerfile documentation typo and content fix
Signed-off-by: Oh Jinkyun <tintypemolly@gmail.com>
2014-09-03 19:28:01 +09:00
Alexandr Morozov
58dc474e65 Merge pull request #7542 from unclejack/refactor_archive_buffering
Refactor archive buffering
2014-09-03 12:39:14 +04:00
unclejack
84d76e556b archive: use pooled bufio readers and writers
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:37:03 +03:00
unclejack
2d2016b81b pkg/pool: add pools for bufio readers & writers
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:36:39 +03:00
unclejack
bd130e72a0 pkg/ioutils: add ReaderErrWrapper to readers
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:36:21 +03:00
unclejack
c93b9e81c0 pkg/ioutils: add NewBufReaderWithDrainbufAndBuffer
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:36:21 +03:00
unclejack
7b6f34057c pkg/ioutils: add WriteCloserWrapper
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:36:21 +03:00
unclejack
76212635b5 move some io related utils to pkg/ioutils
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-03 11:36:21 +03:00
unclejack
2da75f7079 Merge pull request #7315 from vieux/add_pb
add progress bar to ADD
2014-09-03 11:00:31 +03:00
Tibor Vass
426fbee810 Merge pull request #7800 from djbk/master
Cleanup: Typo in job.go
2014-09-02 17:47:18 -07:00
Fred Lifton
23cf3f7407 Adding Docs Deploy process to Docs ReadMe
Additions and revisions to Sven's cherry-pick process doc.

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-09-02 17:44:36 -07:00
Byung Kang
cc84ec3f61 Cleanup: Typo in job.go
Signed-off-by: Byung Kang <byungk91@gmail.com>
2014-09-02 19:37:14 -05:00
Victor Vieux
4e40d09a2b Add a progress bar for ADD <url> <dst>
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-03 00:17:08 +00:00
Jessie Frazelle
f74b901da6 Merge pull request #7839 from LK4D4/embed_state_to_container
Use State as embedded to Container
2014-09-02 15:18:32 -07:00
Alexandr Morozov
e0339d4b88 Use State as embedded to Container
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-03 00:01:11 +04:00
unclejack
6db078dea7 Merge pull request #7191 from tiborvass/test-daemon
Add Daemon restart test along with Daemon utils
2014-09-02 22:40:23 +03:00
Victor Vieux
6eef7de396 Merge pull request #7842 from unclejack/build_delete_context
clean up context on build completion & add test
2014-09-02 12:19:47 -07:00
Tibor Vass
ca24e91408 Merge pull request #7765 from erikh/test_unit_testflags
hack/make: fix test-unit target to propogate TESTFLAGS properly
2014-09-02 12:18:40 -07:00
Tibor Vass
a9971a89cc Add TestDaemonRestartWithRunningContainersPorts
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-09-02 12:13:21 -07:00
Erik Hollensbe
9a2d4e9273 hack/make: fix test-unit target to propogate TESTFLAGS properly
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-02 12:10:47 -07:00
Tibor Vass
054b921a2c Add Daemon test utils
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-09-02 10:58:36 -07:00
unclejack
1858746978 clean up context on build completion & add test
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-02 17:35:25 +03:00
Alexandr Morozov
5f6b420f91 Merge pull request #7833 from crosbymichael/mem-test
Add more error info to TestDockerRunEchoStdoutWithMemoryLimit
2014-09-02 07:51:04 +04:00
Michael Crosby
c0a5ec75c5 Add more error info to TestDockerRunEchoStdoutWithMemoryLimit
This test fails on my CI server often so we need more info when it does
happen with this test.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-01 17:09:52 -07:00
Victor Vieux
0704010313 Merge pull request #7832 from crosbymichael/fix-nat-test
Make nat test less racy and accurate
2014-09-01 16:57:26 -07:00
Michael Crosby
72652c5973 Make nat test less racy and accurate
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-01 16:54:32 -07:00
Michael Crosby
ca63cceae5 Merge pull request #7830 from crosbymichael/update-libcontainer-sep1
Update libcontainer to version 55430d0db7c6bb1198c0bb573a9700a859d5ec26
2014-09-01 16:13:38 -07:00
Victor Vieux
40cc889a7c Merge pull request #7780 from unclejack/disallow_dns_with_net_host
disallow net=host and net=container with links and dns
2014-09-01 15:32:08 -07:00
Michael Crosby
688741df31 Update mount struct with reference
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-01 15:18:30 -07:00
Michael Crosby
cf31787cd0 Update libcontainer to 55430d0db7c6bb1198c0bb573a9
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-01 15:18:25 -07:00
Michael Crosby
7ff488e741 Merge pull request #7829 from crosbymichael/process-config
Refactor exec drivers for multi process
2014-09-01 14:41:24 -07:00
Vishnu Kannan
3a7e07355a Rename 'StdConfig' to 'StreamConfig'.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-01 14:31:01 -07:00
Vishnu Kannan
4aa5da278f Refactoring execdriver.Command and Container structs to support 'docker exec' and other
similar features in the future.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-01 14:30:16 -07:00
James Turnbull
9ffb0f76f2 Merge pull request #7819 from SvenDowideit/debian-wheezy-notes
Debian wheezy notes - minor md tweaks
2014-09-01 15:45:47 -04:00
Victor Vieux
2d8695761d more updates
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-09-01 18:41:42 +00:00
Michael Crosby
efc6c9ba2f Merge pull request #7825 from LK4D4/move_integration_to_cli
Move integration to cli
2014-09-01 11:38:57 -07:00
Anand Patil
eac6a5d789 v1.13 and 1.14 api docs now match runconfig/config.go 2014-09-01 18:33:13 +00:00
Michael Crosby
388ed88042 Merge pull request #7812 from erikh/fix_top
docker top: fix command when multiple arguments are supplied
2014-09-01 11:31:38 -07:00
Michael Crosby
ec87846908 Merge pull request #7809 from LK4D4/use_increment
Use increment operator
2014-09-01 11:16:25 -07:00
Michael Crosby
ac69b661ee Merge pull request #7791 from SvenDowideit/mflag-Visit-returns-nil-flag
fs.Visit() returns nil flag
2014-09-01 11:13:32 -07:00
Victor Vieux
09d3670907 Merge pull request #7814 from erikh/fix_parser_env
Fix panic when `ENV ARG=ARG` is used.
2014-09-01 11:03:21 -07:00
Alexandr Morozov
195cee9983 Move TestRunCidFileCheckIDLength to integration-cli
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-01 20:15:20 +04:00
Alexandr Morozov
8892320835 Move TestRunCidFileCleanupIfEmpty to integration-cli
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-09-01 19:55:39 +04:00
Sven Dowideit
2aaa8892e3 Merge pull request #7820 from SvenDowideit/eik3-exit-doc-patch
alternative to `exit` command: `CTRL-D`
2014-08-31 20:39:23 -07:00
Eike Herzbach
c0c525b3d1 alternative to exit command: CTRL-D
Docker-DCO-1.1-Signed-off-by: Eike Herzbach <eike@herzbach.net> (github: eik3)
2014-09-01 13:38:25 +10:00
Sven Dowideit
ead942156c document the cherry-pick process I'm using to make docs updates
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-01 11:32:52 +10:00
Sven Dowideit
2852037018 Try to go for 80-char lines and a little md wrangling.
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
2014-09-01 09:55:53 +10:00
Vishal Doshi
d27f1bb000 Update debian.md
Add some instructions for Debian 7 (aka Wheezy/Stable)

Signed-off-by: Vishal Doshi <vishal.doshi@gmail.com>
2014-09-01 00:50:49 +05:30
James Turnbull
014471ad39 Merge pull request #7751 from dchen1107/master
Bump containervm version to the latest one: 20140826
2014-08-31 14:16:22 -04:00
James Turnbull
a25594c867 Merge pull request #7805 from nzwsch/patch-1
Update nodejs_web_app.md
2014-08-31 14:14:40 -04:00
Alexandr Morozov
c8999dc326 Merge pull request #7817 from cnf/fix_cli_top_test_priv
Fixed error check using the wrong error value
2014-08-31 19:24:33 +04:00
Frank Rosquin
d93c95a332 Fixed error check using the wrong error value
errorOut was using the err from the previous test.
same as #7816 but on TestTopPrivileged, which I missed last time

Signed-off-by: Frank Rosquin <frank.rosquin@gmail.com>
2014-08-31 16:35:38 +02:00
Alexandr Morozov
d301146c4b Merge pull request #7816 from cnf/fix_cli_top_test
fixed error check using the wrong error value
2014-08-31 18:28:29 +04:00
Frank Rosquin
82c536aacd fixed error check using the wrong error value
errorOut was using the err from the previous test.

Signed-off-by: Frank Rosquin <frank.rosquin@gmail.com>
2014-08-31 16:21:53 +02:00
Erik Hollensbe
d7dd35bbd6 Add a test for the multiple arguments passed to docker top
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-31 05:53:05 -07:00
Erik Hollensbe
a0255ba502 Fix panic when ENV ARG=ARG is used.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-31 05:39:36 -07:00
Erik Hollensbe
394a6d3154 docker top: fix command when multiple arguments are supplied
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-31 01:18:15 -07:00
Alexandr Morozov
16e850fe3e Use increment operator
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-30 21:43:48 +04:00
nzwsch
2d1ec162be Update nodejs_web_app.md 2014-08-30 16:02:47 +09:00
Victor Vieux
280b64bc7b Merge pull request #7775 from LK4D4/merge_state_lock
Merge Container and State mutexes
2014-08-29 11:25:21 -07:00
Michael Crosby
8b74ac6717 Merge pull request #7795 from LK4D4/style_fixes
Some more style fixes
2014-08-29 10:59:37 -07:00
Victor Vieux
9c0b851e4c Merge pull request #6628 from SvenDowideit/6501-list-all-docker-ports
List all ports when calling `docker port container`
2014-08-29 10:57:20 -07:00
Alexandr Morozov
b101022dbe Implement allocating IPs from CIDR within bridge network
Fixes #4986

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-29 16:21:07 +04:00
Alexandr Morozov
42dd48315f More ipallocator refactoring
Now x1.5 faster

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-29 16:20:49 +04:00
Alexandr Morozov
114838cbda Some more style fixes
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-29 15:21:28 +04:00
Alexandr Morozov
517ba44e37 Merge Container and State mutexes
Resolved all deadlocks and fixed race between kill and
monitor.resetContainer
Fixes #7600

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-29 12:56:04 +04:00
SvenDowideit
4e340cedec List all ports when calling docker port container
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-08-29 18:31:51 +10:00
Sven Dowideit
f1934e5979 fs.Visit() returns nil flag
Signed-off-by: Sven Dowideit <SvenDowideit@docker.com>
2014-08-29 15:38:03 +10:00
Victor Vieux
6eaac7d571 Merge pull request #5518 from vbatts/vbatts-save_many
docker save: ability to save multiple images
2014-08-28 18:40:28 -07:00
Vincent Batts
79501dcd4f save many: adding an integration-cli test
Signed-off-by: Vincent Batts <vbatts@redhat.com>
2014-08-28 21:33:13 -04:00
James Turnbull
f1a42fb609 Merge pull request #7789 from SvenDowideit/add-css-for-strong-tag
Give the <strong> tag some CSS (the .content-body resets it)
2014-08-28 18:12:54 -07:00
Fred Lifton
d420b2cce0 Merge pull request #7786 from psftw/volume_removal
Be more explicit about volume lifecycle
2014-08-28 18:11:28 -07:00
SvenDowideit
7de977368c Give the <strong> tag some CSS (the .content-body resets it)
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-08-29 11:08:56 +10:00
Sven Dowideit
2bf41be514 Merge pull request #7769 from fredlf/1.2.0_release-notes
Adding release notes to docs home
2014-08-28 17:37:15 -07:00
Fred Lifton
810c231b91 Fixed typos based on feedback.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-08-28 17:29:09 -07:00
Vincent Batts
e64131d1bf docker save: ability to save multiple images
Now from a single invocation of `docker save`, you can specify multiple
images to include in the output tar, or even just multiple tags of a
particular image/repo.

```
> docker save -o bundle.tar busybox ubuntu:lucid ubuntu:saucy fedora:latest
> tar tf ./bundle.tar | wc -l
42
> tar xOf ./bundle.tar repositories
{"busybox":{"latest":"2d8e5b282c81244037eb15b2068e1c46319c1a42b80493acb128da24b2090739"},"fedora":{"latest":"58394af373423902a1b97f209a31e3777932d9321ef10e64feaaa7b4df609cf9"},"ubuntu":{"lucid":"9cc9ea5ea540116b89e41898dd30858107c1175260fb7ff50322b34704092232","saucy":"9f676bd305a43a931a8d98b13e5840ffbebcd908370765373315926024c7c35e"}}
```

Further, this fixes the bug where the `repositories` file is not created
when saving a specific tag of an image (e.g. ubuntu:latest)

document multi-image save and updated API docs

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
2014-08-28 20:22:33 -04:00
Sven Dowideit
31d2701377 Merge pull request #7749 from hollietealok/master
Doc: Resizing Boot2Docker Volume with VirtualBox
2014-08-28 16:08:29 -07:00
Hollie Teal
0f8d461ed7 Final tweaks.
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-28 13:51:38 -07:00
Peter Salvatore
bfa3d5fa72 Be more explicit about volume removal
Signed-off-by: Peter Salvatore <peter@psftw.com>
2014-08-28 16:44:41 -04:00
Hollie Teal
ce73a3bcf7 Added changes brought up in PR discussion.
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-28 11:04:53 -07:00
Alexandr Morozov
bc41261de0 Merge pull request #7782 from somaopensource/graph_remove_fixme
graph: remove obsolete comments
2014-08-28 20:03:16 +04:00
Daehyeok.Mun
59d58352df graph: remove obsolete comments
Graph.Get function already returns nil when the image doesn't exist so
following comment is obsolete.
FIXME: return nil when the image doesn't exist, instead of an error

Signed-off-by: Daehyeok.Mun <daehyeok@gmail.com>
2014-08-29 00:22:26 +09:00
unclejack
3256050ed4 deny net host + dns and links with container net
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-08-28 16:58:54 +03:00
unclejack
d244e8c379 Merge pull request #7774 from somaopensource/graph_fixme
graph: change argument order of Register function
2014-08-28 16:36:23 +03:00
Daehyeok.Mun
35df24c8e6 graph: change argument order of Register function
This commit is patch for following comment
FIXME: pass img as first argument

Signed-off-by: Daehyeok.Mun <daehyeok@gmail.com>
2014-08-28 20:06:07 +09:00
unclejack
22b585e0fc Merge pull request #7294 from erikh/fix_multiple_attach_test
Fix multiple attach test.
2014-08-28 13:38:28 +03:00
Victor Vieux
d9f8d3ea9f Merge pull request #7461 from erikh/rewrite_dockerfile_parser
Cleanup: Refactor Dockerfile parser
2014-08-27 23:22:47 -07:00
Victor Vieux
a26fc6cae8 Merge pull request #7772 from LK4D4/log_dones
Add logDone logs where it's missing
2014-08-27 22:46:54 -07:00
Alexandr Morozov
3c984a6d15 Add logDone logs where it's missing
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-28 09:25:57 +04:00
Michael Crosby
334dca15b0 Merge pull request #7647 from ewindisch/erw-tarsum-maintainer
Add Eric Windisch to MAINTAINER for tarsum
2014-08-27 20:00:19 -07:00
Michael Crosby
2a5e29adc6 Merge pull request #7677 from erikh/update_hosts_linked_containers
Update /etc/hosts when linked container is restarted
2014-08-27 19:54:09 -07:00
Michael Crosby
77eefbc688 Merge pull request #7672 from cpuguy83/cleanup_volumes_from
Cleanup: applyVolumesFrom
2014-08-27 19:43:16 -07:00
Michael Crosby
345e3811fe Merge pull request #7767 from vieux/move_some_tests
Move some tests
2014-08-27 19:28:31 -07:00
Erik Hollensbe
2ef1dec7e8 builder: Refactors according to @tiborvass's comments
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
305f735080 builder: several fixups from comments
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
a1522ec01c builder: move the evaluator package code directly into builder
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
cb51681a6d builder: Fix handling of ENV references that reference themselves, plus tests.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
1ae4c00a19 builder: fix references to jobs in daemon, make builder a first class
package referring to evaluator

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
3dfe5ddfb9 builder: Remove spurious .gitignores
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
248f4c4f75 builder/parser: Rewrite Parse() to use := instead of var
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
135f54ccbf builder: Remove blankNode(), use &Node{} instead.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
21b15ac920 builder: handle certain classes of JSON errors gracefully
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
4122a981ae builder: negative test support, fix for shykes's broken dockerfile
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
3f5f6b038f builder: comments / documentation
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
d6c0bbc3cb builder: add command handling to evaluator.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:30 -07:00
Erik Hollensbe
bb36902db6 builder: rewrote NewBuildFile according to tibor's comments
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:29 -07:00
Erik Hollensbe
22c46af4b3 builder: parser and beginnings of the evaluator
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:52:29 -07:00
Fred Lifton
1c3b732f8a Adding release notes to docs home
This is a temporary solution until we have a dedicated release notes page with automated content.

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-08-27 18:34:19 -07:00
Erik Hollensbe
f6a2fc4c33 Update networking doc with clarified text regarding links usage
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:23:41 -07:00
Erik Hollensbe
9f09ef18a4 pkg/networkfs/etchosts: tests for Update method
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:23:41 -07:00
Erik Hollensbe
925a3254e7 pkg/graphdb: tests for Parents and Children
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-27 18:23:41 -07:00
Victor Vieux
450740c891 Update /etc/hosts when linked container is restarted
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-08-27 18:23:41 -07:00
Victor Vieux
2b538bd555 remove auth_test.go
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-08-28 00:28:54 +00:00
Victor Vieux
5b27fbc0e2 move TestEntrypoint & TestBindMounts
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-08-28 00:25:10 +00:00
Victor Vieux
96e1c99fb4 Merge pull request #7708 from SvenDowideit/programatic-usage-options
add the [OPTIONS] string automatically if there are flags defined
2014-08-27 16:40:17 -07:00
Victor Vieux
eb9379c5d0 move TestKillDifferentUser
Signed-off-by: Victor Vieux <vieux@docker.com>
2014-08-27 23:34:37 +00:00
Sven Dowideit
7c27c7a096 Merge pull request #7766 from fredlf/update_b2d_upgrading
Updating B2D upgrade instructions for 1.2.0.
2014-08-27 15:53:48 -07:00
SvenDowideit
8c6c4a12b7 add the [OPTIONS] string automatically if there are flags defined
Signed-off-by: SvenDowideit <SvenDowideit@home.org.au>

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-08-28 08:50:50 +10:00
Victor Vieux
0cb672e6a9 Merge pull request #7762 from LK4D4/skip_delete_no_chain_#6904
Skip "no chain" error on deleting chain in Unmap
2014-08-27 14:43:57 -07:00
Fred Lifton
3304d4e984 Updating B2D upgrade instructions for 1.2.0.
Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
2014-08-27 14:16:29 -07:00
Michael Crosby
e0db426ff6 Merge pull request #7764 from vieux/revert
Revert "--help option and help command should print to stdout not stderr"
2014-08-27 12:02:02 -07:00
Victor Vieux
2e489073d9 Revert "--help option and help command should print to stdout not stderr"
This reverts commit 61b129d818.

Signed-off-by: Victor Vieux <vieux@docker.com>
2014-08-27 18:59:13 +00:00
Hollie Teal
77ca0ae9de Added Fred's suggestions.
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-27 11:49:26 -07:00
Michael Crosby
835800fcd5 Merge pull request #7686 from guywithnose/trancateNames
Truncate the names list on ps
2014-08-27 11:46:28 -07:00
Robert Bittle
d2ffcd986f Truncate the names list on ps
Signed-off-by: Robert Bittle <guywithnose@gmail.com>
2014-08-27 14:24:49 -04:00
Victor Vieux
76fd51a478 Merge pull request #6052 from rhatdan/help
--help option and help command should print to stdout not stderr
2014-08-27 11:17:16 -07:00
James Turnbull
7458a82e0b Added Syntax highlighting file for the KDE Kate Editor
Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
2014-08-27 11:16:51 -07:00
Eric Windisch
0bd1c05e5c Restrict repository names from matching hexadecimal strings
To avoid conflicting with layer IDs, repository names must
not be tagged with names that collide with hexadecimal strings.

Signed-off-by: Eric Windisch <eric@windisch.us>
2014-08-27 13:46:10 -04:00
Alexandr Morozov
bd049b3800 Skip "no chain" error on deleting chain in Unmap
Fixes #6904
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-27 20:24:27 +04:00
Michael Crosby
1385b2d293 Merge pull request #7740 from LK4D4/registry_style
Style fixes for registry/registry.go
2014-08-26 18:02:11 -07:00
Brian Goff
7495fbc0e3 Cleanup: applyVolumesFrom
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-08-26 20:52:58 -04:00
Dawn Chen
9cd77818bb Bump containervm version to the latest one: 20140826 2014-08-26 16:59:21 -07:00
Hollie Teal
161cc21f24 Final changes.
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-26 14:01:10 -07:00
James Turnbull
4fe6115fb1 Merge pull request #7741 from LK4D4/bump_docs_to_1.15
Bump docs and api to 1.15
2014-08-26 13:44:05 -07:00
James Turnbull
5b6c25f751 Merge pull request #7735 from SvenDowideit/lxcconf-api-docs
Lxcconf api docs
2014-08-26 13:43:48 -07:00
Michael Crosby
b458dd1dfb Merge pull request #7745 from LK4D4/fix_docker_host_panic
Fix panic for DOCKER_HOST without ://
2014-08-26 11:23:30 -07:00
Tibor Vass
c4a190db0c Merge pull request #7744 from LK4D4/fix_race_cleanup_start_#6904
Fix race condition between cleanup and Start
2014-08-26 14:17:11 -04:00
Michael Crosby
55f7dd8198 Merge pull request #7642 from LK4D4/style_fixes
Style fixes for daemon package
2014-08-26 10:59:05 -07:00
Michael Crosby
89f64712fa Merge pull request #7702 from LK4D4/fix_panic_on_bad_device_#7701
Handle error from GetDevice early
2014-08-26 10:53:40 -07:00
Alexandr Morozov
12ff89a390 Fix race condition between cleanup and Start
There was problem when Start might be before cleanup

Fixes #6904

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 20:57:12 +04:00
Alexandr Morozov
660cc4a267 Fix panic for DOCKER_HOST without ://
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 20:32:10 +04:00
Tibor Vass
63ed18ad11 Merge pull request #7615 from crosbymichael/fix-utils-panic
Fix panic in validate context for build
2014-08-26 10:30:42 -04:00
Alexandr Morozov
e261618b24 Bump docs and api to 1.15
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 13:08:50 +04:00
Alexandr Morozov
45a2923874 Style fixes for registry/registry.go
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 12:28:40 +04:00
Alexandr Morozov
698392cb51 Remove redundant elses
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 09:28:54 +04:00
Alexandr Morozov
1ba15b8aca Use ++ instead of += 1
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-26 09:27:07 +04:00
SvenDowideit
b0edced87f Fix the other API docs to use an array of key/values
as per #7706

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-08-26 11:36:25 +10:00
getvictor
216ab880f9 Updating LxcConf to match Docker command line
I've changed LxcConf on a previous API document. Not sure why it keeps getting changed back. I'm seeing Docker 1.2.0 command-line calls are still using the array of key/values.

Docker-DCO-1.1-Signed-off-by: getvictor <victor@victoreda.com> (github: SvenDowideit)
2014-08-26 11:36:25 +10:00
Sven Dowideit
a05d8d4f4f Merge pull request #7733 from Djelibeybi/oraclelinux-docs
Oracle Linux docs
2014-08-25 18:14:36 -07:00
Avi Miller
fcad8ee83a Add Oracle Linux specific documentation for installation of Docker from Oracle Linux repositories on Oracle Linux 6 and 7.
Signed-off-by: Avi Miller <avi.miller@oracle.com>
2014-08-26 11:10:09 +10:00
Sven Dowideit
849086d3d9 Merge pull request #7732 from SvenDowideit/ubuntu-backported-kernel
Ubuntu backported kernel
2014-08-25 17:16:34 -07:00
SvenDowideit
93d574298d small word change
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
2014-08-26 10:15:12 +10:00
Hollie Teal
1d1bb2ae45 Image additions and copy changes.
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-25 16:50:55 -07:00
Sven Dowideit
97c7b0115b Merge pull request #7603 from kuon/centos7
Added manual installation instruction for Centos7 and note about firewalld.
2014-08-25 16:49:09 -07:00
Michael Crosby
b0abd6de63 Merge pull request #7574 from crosbymichael/update-restart-docs
Update flag usages and docs for max restart count
2014-08-25 16:26:06 -07:00
Michael Crosby
2bdfbab23d Merge pull request #7622 from rajdeepd/master
Added Test case for Engine shutdown
2014-08-25 15:57:11 -07:00
Michael Crosby
228eda4fd5 Merge pull request #7629 from LK4D4/fix_follow_hang_on_stop
Fix logs -f hanging on stopped containers
2014-08-25 15:24:20 -07:00
Michael Crosby
7556a42453 Merge pull request #7716 from coolljt0725/master
Fix the bug of docker import command when import a image with a tag use format 'URL|- [REPOSITORY[:TAG]]'
2014-08-25 15:11:50 -07:00
Lei Jitang
7e72ed70f9 add docker import test with a tag. Fixes #7714
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2014-08-26 15:51:22 +08:00
Lei Jitang
79cf839527 Fix the bug of docker import command when import a image with a tag use format 'URL|- [REPOSITORY[:TAG]]'.Fixes #7714
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2014-08-26 15:51:22 +08:00
Michael Crosby
cd776cdd77 Fix panic in validate context for build
Fixes #7611

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-25 14:25:31 -07:00
Tibor Vass
34438efffe Merge pull request #7659 from somaopensource/soma
daemon: rename from "delete" job to "rm"
2014-08-25 15:54:14 -04:00
Michael Crosby
321df7fd61 Merge pull request #7649 from tianon/vendor-optional-go
Optionalize the "hg clone" of Go, since it takes forever
2014-08-25 12:00:23 -07:00
Victor Vieux
d1544a0930 Merge pull request #7683 from LK4D4/fix_build_hang_pipe_#7680
Skip permissions check on named pipes
2014-08-25 12:00:11 -07:00
Alexandr Morozov
07f2e79486 Skip permissions check on named pipes
Fixes #7680

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-25 22:59:53 +04:00
Victor Vieux
e1defe71c3 Merge pull request #7691 from carmstrong/patch-1
Fix typo for --restart deprecation
2014-08-25 11:13:27 -07:00
Michael Crosby
2c9789bbf7 Merge pull request #7725 from erikh/fix_registry_test
fix return values in registry mock service
2014-08-25 10:56:00 -07:00
Erik Hollensbe
e81b686924 fix return values in registry mock service
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-25 10:29:38 -07:00
James Turnbull
bef33cf88a Merge pull request #7700 from jamtur01/relnotes
Removed deprecated release notes
2014-08-25 07:13:11 -07:00
Nicolas Goy
d4a53a7bce Added manual installation instruction for Centos7.
Added a note about firewalld.

Signed-off-by: Nicolas Goy <kuon@goyman.com>
2014-08-25 04:00:11 +02:00
Alexandr Morozov
17b95ecb08 Handle error from GetDevice early
Also more verbose error.

Fixes panic from #7701

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-24 14:09:30 +04:00
James Turnbull
df38eb4d43 Removed deprecated release notes
Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
2014-08-23 20:01:41 -04:00
Hollie Teal
e4ff140fdd Additional formatting and markdown changes to B2D volume resize doc
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-22 18:19:58 -07:00
Hollie Teal
db3db49e9c Initial commit: Increase Boot2Docker Volume + images
Signed-off-by: Hollie Teal <hollie@docker.com>
2014-08-22 17:06:28 -07:00
Chris Armstrong
ef9a5926e9 Fix typo for --restart deprecation
Signed-off-by: Chris Armstrong <chris@opdemand.com>
2014-08-22 12:56:43 -07:00
James Turnbull
6bc773b2c1 Merge pull request #7684 from averagehuman/patch-1
Update usingdocker.md
2014-08-22 13:16:33 -04:00
averagehuman
fe845c4da8 Update usingdocker.md
Minor rewording and removal of unnecessary apostrophe.
2014-08-22 17:48:26 +01:00
Tianon Gravi
651f521e17 Merge pull request #7632 from erikh/fix_check_config
fix check-config.sh to check for CGROUP_PERF
2014-08-22 11:42:08 -05:00
Victor Vieux
094cd7040b Merge pull request #7638 from vivekdasgupta/minor-fixes
Fix data space reporting from Kb/Mb to KB/MB
2014-08-22 11:40:49 -05:00
Victor Vieux
bd7c7febb9 Merge pull request #7668 from docker/merge_release_v1.2.0
Merge release v1.2.0
2014-08-22 11:18:48 -05:00
Erik Hollensbe
01094c1568 Fix multiple attach test.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-22 03:58:05 -07:00
Victor Vieux
61b309f0d2 Change version to 1.2.0-dev 2014-08-21 15:55:00 -04:00
Victor Vieux
380aef2dc1 Merge remote-tracking branch 'origin/release' 2014-08-21 15:54:02 -04:00
Dan Walsh
61b129d818 --help option and help command should print to stdout not stderr
--help and help are successful commands so output should not go to error.

QE teams have requested this change, also users doing docker help | less
or docker run --help | less would expect this to work.

Usage statement should only be printed when the user asks for it.
Errors should print error message and then suggest the docker COMMAND --help
command to see usage information.

The current behaviour causes the user to have to search for the error message
and sometimes scrolls right off the screen.  For example a error on a
"docker run" command is very difficult to diagnose.

Finally erros should always exit with a non 0 exit code, if the user
makes a CLI error.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-08-21 15:35:20 -04:00
Victor Vieux
7649264eb8 Merge pull request #7644 from vieux/bump_v1.2.0
Bump v1.2.0
2014-08-21 14:32:00 -05:00
Hollie Teal
c87d9a1de6 Clean up typos in hub_registry_spec.md
Couple of instances of incorrect articles (e.g. "an Docker Hub").
2014-08-21 11:04:25 -07:00
Vivek Dasgupta
a327d9b91e Fix data space reporting from Kb/Mb to KB/MB
Docker-DCO-1.1-Signed-off-by: Vivek Dasgupta <vdasgupt@redhat.com> (github: vivekdasgupta)
2014-08-21 21:03:44 +05:30
limsy
239e932485 daemon: rename from "delete" job to "rm"
This commit fixes following FIXMEs:

// FIXME: rename "delete" to "rm" for consistency with the CLI command
// FIXME: rename ContainerDestroy to ContainerRm for consistency with the CLI command

Signed-off-by: lim seong yeol <seongyeol37@gmail.com>
2014-08-21 19:58:26 +09:00
dragon788
27f44b9bb1 Add link to Ubuntu notes about LTSEnablementStack
When running Ubuntu with a graphical environment, the kernel version MUST match the Xorg version. Only installing the suggested packages above breaks Unity for anything other than 2D mode (in VMware and probably native).
Signed-off-by: Ethan Spoelstra <ewspoelstra@computerphreaks.com>
2014-08-20 22:23:34 -05:00
Tianon Gravi
78c6882567 Optionalize the "hg clone" of Go, since it takes forever (now, to update our Go version too, we need to explicitly "./hack/vendor.sh --go")
Signed-off-by: Andrew Page <admwiggin@gmail.com>
2014-08-20 14:17:11 -06:00
Eric Windisch
cd71f92a7f Add Eric Windisch to MAINTAINER for tarsum
This code is vital to the security of the project and it is important
we assure it is well-maintained and guarded.

I am vested in assuring this code maintains security and
provides as much compatibility as possible between releases.

Signed-off-by: Eric Windisch <eric@windisch.us>
2014-08-20 11:19:46 -07:00
Alexandr Morozov
f04ef96e07 Test for following logs for stopped container
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-20 20:02:56 +04:00
Erik Hollensbe
ce3c1f376c fix check-config.sh to check for CGROUP_PERF
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-08-20 13:37:39 +00:00
Alexandr Morozov
badf8247af Fix logs -f hanging on stopped containers
Fixes #7020

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-19 22:23:02 +04:00
Rajdeep Dua
0800f8cc19 Added Test case for Engine shutdown
Docker-DCO-1.1-Signed-off-by: Rajdeep Dua <dua_rajdeep@yahoo.com> (github: rajdeepd)
2014-08-19 04:59:13 -07:00
Michael Crosby
5ad4879d2a Update flag usages and docs for max restart count
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-13 18:24:33 -07:00
580 changed files with 34613 additions and 12001 deletions

14
.drone.yml Executable file
View File

@@ -0,0 +1,14 @@
image: dockercore/docker
env:
- AUTO_GOPATH=1
- DOCKER_GRAPHDRIVER=vfs
- DOCKER_EXECDRIVER=native
script:
# Setup the DockerInDocker environment.
- hack/dind
# Tests relying on StartWithBusybox make Drone time out.
- rm integration-cli/docker_cli_daemon_test.go
- rm integration-cli/docker_cli_exec_test.go
# Validate and test.
- hack/make.sh validate-dco validate-gofmt
- hack/make.sh binary cross test-unit test-integration-cli test-integration

View File

@@ -17,6 +17,15 @@ sudo: false
install:
- export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper' # btrfs and devicemapper fail to compile thanks to a couple missing headers (which we can't install thanks to "sudo: false")
- export AUTO_GOPATH=1
# some of Docker's unit tests don't work inside Travis (yet!), so we purge those test files for now
- rm -f daemon/graphdriver/btrfs/*_test.go # fails to compile (missing header)
- rm -f daemon/graphdriver/devmapper/*_test.go # fails to compile (missing header)
- rm -f daemon/execdriver/lxc/*_test.go # fails to run (missing "lxc-start")
- rm -f daemon/graphdriver/aufs/*_test.go # fails to run ("backing file system is unsupported for this graph driver")
- rm -f daemon/graphdriver/vfs/*_test.go # fails to run (not root, which these tests assume "/var/tmp/... no owned by uid 0")
- rm -f daemon/networkdriver/bridge/*_test.go # fails to run ("Failed to initialize network driver")
- rm -f graph/*_test.go # fails to run ("mkdir /tmp/docker-test.../vfs/dir/foo/etc/postgres: permission denied")
- rm -f pkg/mount/*_test.go # fails to run ("permission denied")
before_script:
- env | sort
@@ -24,7 +33,7 @@ before_script:
script:
- hack/make.sh validate-dco
- hack/make.sh validate-gofmt
- ./hack/make.sh dynbinary
- DOCKER_CLIENTONLY=1 ./hack/make.sh dynbinary
- ./hack/make.sh dynbinary dyntest-unit
# vim:set sw=2 ts=2:

View File

@@ -1,5 +1,67 @@
# Changelog
## 1.3.3 (2014-12-11)
#### Security
- Fix path traversal vulnerability in processing of absolute symbolic links (CVE-2014-9356)
- Fix decompression of xz image archives, preventing privilege escalation (CVE-2014-9357)
- Validate image IDs (CVE-2014-9358)
#### Runtime
- Fix an issue when image archives are being read slowly
#### Client
- Fix a regression related to stdin redirection
- Fix a regression with `docker cp` when destination is the current directory
## 1.3.2 (2014-11-20)
#### Security
- Fix tar breakout vulnerability
* Extractions are now sandboxed chroot
- Security options are no longer committed to images
#### Runtime
- Fix deadlock in `docker ps -f exited=1`
- Fix a bug when `--volumes-from` references a container that failed to start
#### Registry
+ `--insecure-registry` now accepts CIDR notation such as 10.1.0.0/16
* Private registries whose IPs fall in the 127.0.0.0/8 range do no need the `--insecure-registry` flag
- Skip the experimental registry v2 API when mirroring is enabled
## 1.3.1 (2014-10-28)
#### Security
* Prevent fallback to SSL protocols < TLS 1.0 for client, daemon and registry
+ Secure HTTPS connection to registries with certificate verification and without HTTP fallback unless `--insecure-registry` is specified
#### Runtime
- Fix issue where volumes would not be shared
#### Client
- Fix issue with `--iptables=false` not automatically setting `--ip-masq=false`
- Fix docker run output to non-TTY stdout
#### Builder
- Fix escaping `$` for environment variables
- Fix issue with lowercase `onbuild` Dockerfile instruction
- Restrict envrionment variable expansion to `ENV`, `ADD`, `COPY`, `WORKDIR`, `EXPOSE`, `VOLUME` and `USER`
## 1.3.0 (2014-10-14)
#### Notable features since 1.2.0
+ Docker `exec` allows you to run additional processes inside existing containers
+ Docker `create` gives you the ability to create a container via the CLI without executing a process
+ `--security-opts` options to allow user to customize container labels and apparmor profiles
+ Docker `ps` filters
- Wildcard support to COPY/ADD
+ Move production URLs to get.docker.com from get.docker.io
+ Allocate IP address on the bridge inside a valid CIDR
+ Use drone.io for PR and CI testing
+ Ability to setup an official registry mirror
+ Ability to save multiple images with docker `save`
## 1.2.0 (2014-08-20)
#### Runtime

View File

@@ -59,7 +59,7 @@ RUN cd /usr/local/lvm2 && ./configure --enable-static_link && make device-mapper
# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
# Install Go
RUN curl -sSL https://golang.org/dl/go1.3.1.src.tar.gz | tar -v -C /usr/local -xz
RUN curl -sSL https://golang.org/dl/go1.3.3.src.tar.gz | tar -v -C /usr/local -xz
ENV PATH /usr/local/go/bin:$PATH
ENV GOPATH /go:/go/src/github.com/docker/docker/vendor
ENV PATH /go/bin:$PATH
@@ -75,10 +75,10 @@ ENV GOARM 5
RUN cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
# Grab Go's cover tool for dead-simple code coverage testing
RUN go get code.google.com/p/go.tools/cmd/cover
RUN go get golang.org/x/tools/cmd/cover
# TODO replace FPM with some very minimal debhelper stuff
RUN gem install --no-rdoc --no-ri fpm --version 1.0.2
RUN gem install --no-rdoc --no-ri fpm --version 1.3.2
# Install man page generator
RUN mkdir -p /go/src/github.com/cpuguy83 \
@@ -89,8 +89,11 @@ RUN mkdir -p /go/src/github.com/cpuguy83 \
# Get the "busybox" image source so we can build locally instead of pulling
RUN git clone -b buildroot-2014.02 https://github.com/jpetazzo/docker-busybox.git /docker-busybox
# Get the "cirros" image source so we can import it instead of fetching it during tests
RUN curl -sSL -o /cirros.tar.gz https://github.com/ewindisch/docker-cirros/raw/1cded459668e8b9dbf4ef976c94c05add9bbd8e9/cirros-0.3.0-x86_64-lxc.tar.gz
# Setup s3cmd config
RUN /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY' > /.s3cfg
RUN /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY' > $HOME/.s3cfg
# Set user.email so crosbymichael's in-container merge commits go smoothly
RUN git config --global user.email 'docker-dummy@example.com'

View File

@@ -12,7 +12,7 @@ DOCKER_IMAGE := docker$(if $(GIT_BRANCH),:$(GIT_BRANCH))
DOCKER_DOCS_IMAGE := docker-docs$(if $(GIT_BRANCH),:$(GIT_BRANCH))
DOCKER_MOUNT := $(if $(BINDDIR),-v "$(CURDIR)/$(BINDDIR):/go/src/github.com/docker/docker/$(BINDDIR)")
DOCKER_RUN_DOCKER := docker run --rm -it --privileged -e TESTFLAGS -e TESTDIRS -e DOCKER_GRAPHDRIVER -e DOCKER_EXECDRIVER $(DOCKER_MOUNT) "$(DOCKER_IMAGE)"
DOCKER_RUN_DOCKER := docker run --rm -it --privileged -e TIMEOUT -e BUILDFLAGS -e TESTFLAGS -e TESTDIRS -e DOCKER_GRAPHDRIVER -e DOCKER_EXECDRIVER $(DOCKER_MOUNT) "$(DOCKER_IMAGE)"
# to allow `make DOCSDIR=docs docs-shell`
DOCKER_RUN_DOCS := docker run --rm -it $(if $(DOCSDIR),-v $(CURDIR)/$(DOCSDIR):/$(DOCSDIR)) -e AWS_S3_BUCKET

View File

@@ -1 +1 @@
1.2.0
1.3.3

View File

@@ -13,6 +13,7 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/docker/libtrust"
)
type DockerCli struct {
@@ -22,10 +23,17 @@ type DockerCli struct {
in io.ReadCloser
out io.Writer
err io.Writer
isTerminal bool
terminalFd uintptr
key libtrust.PrivateKey
tlsConfig *tls.Config
scheme string
// inFd holds file descriptor of the client's STDIN, if it's a valid file
inFd uintptr
// outFd holds file descriptor of the client's STDOUT, if it's a valid file
outFd uintptr
// isTerminalIn describes if client's STDIN is a TTY
isTerminalIn bool
// isTerminalOut describes if client's STDOUT is a TTY
isTerminalOut bool
}
var funcMap = template.FuncMap{
@@ -35,11 +43,15 @@ var funcMap = template.FuncMap{
},
}
func (cli *DockerCli) getMethod(name string) (func(...string) error, bool) {
if len(name) == 0 {
return nil, false
func (cli *DockerCli) getMethod(args ...string) (func(...string) error, bool) {
camelArgs := make([]string, len(args))
for i, s := range args {
if len(s) == 0 {
return nil, false
}
camelArgs[i] = strings.ToUpper(s[:1]) + strings.ToLower(s[1:])
}
methodName := "Cmd" + strings.ToUpper(name[:1]) + strings.ToLower(name[1:])
methodName := "Cmd" + strings.Join(camelArgs, "")
method := reflect.ValueOf(cli).MethodByName(methodName)
if !method.IsValid() {
return nil, false
@@ -49,6 +61,12 @@ func (cli *DockerCli) getMethod(name string) (func(...string) error, bool) {
// Cmd executes the specified command
func (cli *DockerCli) Cmd(args ...string) error {
if len(args) > 1 {
method, exists := cli.getMethod(args[:2]...)
if exists {
return method(args[2:]...)
}
}
if len(args) > 0 {
method, exists := cli.getMethod(args[0])
if !exists {
@@ -63,7 +81,11 @@ func (cli *DockerCli) Cmd(args ...string) error {
func (cli *DockerCli) Subcmd(name, signature, description string) *flag.FlagSet {
flags := flag.NewFlagSet(name, flag.ContinueOnError)
flags.Usage = func() {
fmt.Fprintf(cli.err, "\nUsage: docker %s %s\n\n%s\n\n", name, signature, description)
options := ""
if flags.FlagCountUndeprecated() > 0 {
options = "[OPTIONS] "
}
fmt.Fprintf(cli.err, "\nUsage: docker %s %s%s\n\n%s\n\n", name, options, signature, description)
flags.PrintDefaults()
os.Exit(2)
}
@@ -78,11 +100,13 @@ func (cli *DockerCli) LoadConfigFile() (err error) {
return err
}
func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string, tlsConfig *tls.Config) *DockerCli {
func NewDockerCli(in io.ReadCloser, out, err io.Writer, key libtrust.PrivateKey, proto, addr string, tlsConfig *tls.Config) *DockerCli {
var (
isTerminal = false
terminalFd uintptr
scheme = "http"
inFd uintptr
outFd uintptr
isTerminalIn = false
isTerminalOut = false
scheme = "http"
)
if tlsConfig != nil {
@@ -90,24 +114,35 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string, tlsC
}
if in != nil {
if file, ok := in.(*os.File); ok {
inFd = file.Fd()
isTerminalIn = term.IsTerminal(inFd)
}
}
if out != nil {
if file, ok := out.(*os.File); ok {
terminalFd = file.Fd()
isTerminal = term.IsTerminal(terminalFd)
outFd = file.Fd()
isTerminalOut = term.IsTerminal(outFd)
}
}
if err == nil {
err = out
}
return &DockerCli{
proto: proto,
addr: addr,
in: in,
out: out,
err: err,
isTerminal: isTerminal,
terminalFd: terminalFd,
tlsConfig: tlsConfig,
scheme: scheme,
proto: proto,
addr: addr,
in: in,
out: out,
err: err,
key: key,
inFd: inFd,
outFd: outFd,
isTerminalIn: isTerminalIn,
isTerminalOut: isTerminalOut,
tlsConfig: tlsConfig,
scheme: scheme,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@ package client
import (
"crypto/tls"
"errors"
"fmt"
"io"
"net"
@@ -10,29 +11,125 @@ import (
"os"
"runtime"
"strings"
"time"
"github.com/docker/docker/api"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/utils"
)
type tlsClientCon struct {
*tls.Conn
rawConn net.Conn
}
func (c *tlsClientCon) CloseWrite() error {
// Go standard tls.Conn doesn't provide the CloseWrite() method so we do it
// on its underlying connection.
if cwc, ok := c.rawConn.(interface {
CloseWrite() error
}); ok {
return cwc.CloseWrite()
}
return nil
}
func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) {
return tlsDialWithDialer(new(net.Dialer), network, addr, config)
}
// We need to copy Go's implementation of tls.Dial (pkg/cryptor/tls/tls.go) in
// order to return our custom tlsClientCon struct which holds both the tls.Conn
// object _and_ its underlying raw connection. The rationale for this is that
// we need to be able to close the write end of the connection when attaching,
// which tls.Conn does not provide.
func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) {
// We want the Timeout and Deadline values from dialer to cover the
// whole process: TCP connection and TLS handshake. This means that we
// also need to start our own timers now.
timeout := dialer.Timeout
if !dialer.Deadline.IsZero() {
deadlineTimeout := dialer.Deadline.Sub(time.Now())
if timeout == 0 || deadlineTimeout < timeout {
timeout = deadlineTimeout
}
}
var errChannel chan error
if timeout != 0 {
errChannel = make(chan error, 2)
time.AfterFunc(timeout, func() {
errChannel <- errors.New("")
})
}
rawConn, err := dialer.Dial(network, addr)
if err != nil {
return nil, err
}
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
colonPos = len(addr)
}
hostname := addr[:colonPos]
// If no ServerName is set, infer the ServerName
// from the hostname we're connecting to.
if config.ServerName == "" {
// Make a copy to avoid polluting argument or default.
c := *config
c.ServerName = hostname
config = &c
}
conn := tls.Client(rawConn, config)
if timeout == 0 {
err = conn.Handshake()
} else {
go func() {
errChannel <- conn.Handshake()
}()
err = <-errChannel
}
if err != nil {
rawConn.Close()
return nil, err
}
// This is Docker difference with standard's crypto/tls package: returned a
// wrapper which holds both the TLS and raw connections.
return &tlsClientCon{conn, rawConn}, nil
}
func (cli *DockerCli) dial() (net.Conn, error) {
if cli.tlsConfig != nil && cli.proto != "unix" {
return tls.Dial(cli.proto, cli.addr, cli.tlsConfig)
// Notice this isn't Go standard's tls.Dial function
return tlsDial(cli.proto, cli.addr, cli.tlsConfig)
}
return net.Dial(cli.proto, cli.addr)
}
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer) error {
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, data interface{}) error {
defer func() {
if started != nil {
close(started)
}
}()
req, err := http.NewRequest(method, fmt.Sprintf("/v%s%s", api.APIVERSION, path), nil)
params, err := cli.encodeData(data)
if err != nil {
return err
}
req, err := http.NewRequest(method, fmt.Sprintf("/v%s%s", api.APIVERSION, path), params)
if err != nil {
return err
}
@@ -64,20 +161,20 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
var oldState *term.State
if in != nil && setRawTerminal && cli.isTerminal && os.Getenv("NORAW") == "" {
oldState, err = term.SetRawTerminal(cli.terminalFd)
if in != nil && setRawTerminal && cli.isTerminalIn && os.Getenv("NORAW") == "" {
oldState, err = term.SetRawTerminal(cli.inFd)
if err != nil {
return err
}
defer term.RestoreTerminal(cli.terminalFd, oldState)
defer term.RestoreTerminal(cli.inFd, oldState)
}
if stdout != nil || stderr != nil {
receiveStdout = utils.Go(func() (err error) {
receiveStdout = promise.Go(func() (err error) {
defer func() {
if in != nil {
if setRawTerminal && cli.isTerminal {
term.RestoreTerminal(cli.terminalFd, oldState)
if setRawTerminal && cli.isTerminalIn {
term.RestoreTerminal(cli.inFd, oldState)
}
// For some reason this Close call blocks on darwin..
// As the client exists right after, simply discard the close
@@ -92,24 +189,23 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
if setRawTerminal && stdout != nil {
_, err = io.Copy(stdout, br)
} else {
_, err = utils.StdCopy(stdout, stderr, br)
_, err = stdcopy.StdCopy(stdout, stderr, br)
}
log.Debugf("[hijack] End of stdout")
return err
})
}
sendStdin := utils.Go(func() error {
sendStdin := promise.Go(func() error {
if in != nil {
io.Copy(rwc, in)
log.Debugf("[hijack] End of stdin")
}
if tcpc, ok := rwc.(*net.TCPConn); ok {
if err := tcpc.CloseWrite(); err != nil {
log.Debugf("Couldn't send EOF: %s", err)
}
} else if unixc, ok := rwc.(*net.UnixConn); ok {
if err := unixc.CloseWrite(); err != nil {
if conn, ok := rwc.(interface {
CloseWrite() error
}); ok {
if err := conn.CloseWrite(); err != nil {
log.Debugf("Couldn't send EOF: %s", err)
}
}
@@ -124,7 +220,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
}
}
if !cli.isTerminal {
if !cli.isTerminalIn {
if err := <-sendStdin; err != nil {
log.Debugf("Error sendStdin: %s", err)
return err

View File

@@ -16,11 +16,13 @@ import (
"strconv"
"strings"
"syscall"
"time"
"github.com/docker/docker/api"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
@@ -34,30 +36,46 @@ func (cli *DockerCli) HTTPClient() *http.Client {
tr := &http.Transport{
TLSClientConfig: cli.tlsConfig,
Dial: func(network, addr string) (net.Conn, error) {
return net.Dial(cli.proto, cli.addr)
// Why 32? See issue 8035
return net.DialTimeout(cli.proto, cli.addr, 32*time.Second)
},
}
if cli.proto == "unix" {
// XXX workaround for net/http Transport which caches connections, but is
// intended for tcp connections, not unix sockets.
tr.DisableKeepAlives = true
// no need in compressing for local communications
tr.DisableCompression = true
}
return &http.Client{Transport: tr}
}
func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo bool) (io.ReadCloser, int, error) {
func (cli *DockerCli) encodeData(data interface{}) (*bytes.Buffer, error) {
params := bytes.NewBuffer(nil)
if data != nil {
if env, ok := data.(engine.Env); ok {
if err := env.Encode(params); err != nil {
return nil, -1, err
return nil, err
}
} else {
buf, err := json.Marshal(data)
if err != nil {
return nil, -1, err
return nil, err
}
if _, err := params.Write(buf); err != nil {
return nil, -1, err
return nil, err
}
}
}
return params, nil
}
func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo bool) (io.ReadCloser, int, error) {
params, err := cli.encodeData(data)
if err != nil {
return nil, -1, err
}
req, err := http.NewRequest(method, fmt.Sprintf("/v%s%s", api.APIVERSION, path), params)
if err != nil {
return nil, -1, err
@@ -108,6 +126,7 @@ func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo b
}
return nil, resp.StatusCode, fmt.Errorf("Error response from daemon: %s", bytes.TrimSpace(body))
}
return resp.Body, resp.StatusCode, nil
}
@@ -120,7 +139,7 @@ func (cli *DockerCli) streamHelper(method, path string, setRawTerminal bool, in
in = bytes.NewReader([]byte{})
}
req, err := http.NewRequest(method, fmt.Sprintf("http://v%s%s", api.APIVERSION, path), in)
req, err := http.NewRequest(method, fmt.Sprintf("/v%s%s", api.APIVERSION, path), in)
if err != nil {
return err
}
@@ -157,14 +176,14 @@ func (cli *DockerCli) streamHelper(method, path string, setRawTerminal bool, in
}
if api.MatchesContentType(resp.Header.Get("Content-Type"), "application/json") {
return utils.DisplayJSONMessagesStream(resp.Body, stdout, cli.terminalFd, cli.isTerminal)
return utils.DisplayJSONMessagesStream(resp.Body, stdout, cli.outFd, cli.isTerminalOut)
}
if stdout != nil || stderr != nil {
// When TTY is ON, use regular copy
if setRawTerminal {
_, err = io.Copy(stdout, resp.Body)
} else {
_, err = utils.StdCopy(stdout, stderr, resp.Body)
_, err = stdcopy.StdCopy(stdout, stderr, resp.Body)
}
log.Debugf("[stream] End of stdout")
return err
@@ -172,7 +191,7 @@ func (cli *DockerCli) streamHelper(method, path string, setRawTerminal bool, in
return nil
}
func (cli *DockerCli) resizeTty(id string) {
func (cli *DockerCli) resizeTty(id string, isExec bool) {
height, width := cli.getTtySize()
if height == 0 && width == 0 {
return
@@ -180,7 +199,15 @@ func (cli *DockerCli) resizeTty(id string) {
v := url.Values{}
v.Set("h", strconv.Itoa(height))
v.Set("w", strconv.Itoa(width))
if _, _, err := readBody(cli.call("POST", "/containers/"+id+"/resize?"+v.Encode(), nil, false)); err != nil {
path := ""
if !isExec {
path = "/containers/" + id + "/resize?"
} else {
path = "/exec/" + id + "/resize?"
}
if _, _, err := readBody(cli.call("POST", path+v.Encode(), nil, false)); err != nil {
log.Debugf("Error resize: %s", err)
}
}
@@ -219,24 +246,24 @@ func getExitCode(cli *DockerCli, containerId string) (bool, int, error) {
return state.GetBool("Running"), state.GetInt("ExitCode"), nil
}
func (cli *DockerCli) monitorTtySize(id string) error {
cli.resizeTty(id)
func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
cli.resizeTty(id, isExec)
sigchan := make(chan os.Signal, 1)
gosignal.Notify(sigchan, syscall.SIGWINCH)
go func() {
for _ = range sigchan {
cli.resizeTty(id)
cli.resizeTty(id, isExec)
}
}()
return nil
}
func (cli *DockerCli) getTtySize() (int, int) {
if !cli.isTerminal {
if !cli.isTerminalOut {
return 0, 0
}
ws, err := term.GetWinsize(cli.terminalFd)
ws, err := term.GetWinsize(cli.outFd)
if err != nil {
log.Debugf("Error getting size: %s", err)
if ws == nil {

View File

@@ -12,7 +12,7 @@ import (
)
const (
APIVERSION version.Version = "1.14"
APIVERSION version.Version = "1.15"
DEFAULTHTTPHOST = "127.0.0.1"
DEFAULTUNIXSOCKET = "/var/run/docker.sock"
)

View File

@@ -1,3 +1,2 @@
Victor Vieux <vieux@docker.com> (@vieux)
# off the grid until september
# Johan Euphrosine <proppy@google.com> (@proppy)
Johan Euphrosine <proppy@google.com> (@proppy)

View File

@@ -28,6 +28,7 @@ import (
"github.com/docker/docker/pkg/listenbuffer"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/systemd"
"github.com/docker/docker/pkg/version"
"github.com/docker/docker/registry"
@@ -50,6 +51,24 @@ func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
return conn, conn, nil
}
// Check to make sure request's Content-Type is application/json
func checkForJson(r *http.Request) error {
ct := r.Header.Get("Content-Type")
// No Content-Type header is ok as long as there's no Body
if ct == "" {
if r.Body == nil || r.ContentLength == 0 {
return nil
}
}
// Otherwise it better be json
if api.MatchesContentType(ct, "application/json") {
return nil
}
return fmt.Errorf("Content-Type specified (%s) must be 'application/json'", ct)
}
//If we don't do this, POST method without Content-type (even with empty body) will fail
func parseForm(r *http.Request) error {
if r == nil {
@@ -397,8 +416,8 @@ func getContainersLogs(eng *engine.Engine, version version.Version, w http.Respo
outStream = utils.NewWriteFlusher(w)
if c.GetSubEnv("Config") != nil && !c.GetSubEnv("Config").GetBool("Tty") && version.GreaterThanOrEqualTo("1.6") {
errStream = utils.NewStdWriter(outStream, utils.Stderr)
outStream = utils.NewStdWriter(outStream, utils.Stdout)
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
} else {
errStream = outStream
}
@@ -438,6 +457,11 @@ func postCommit(eng *engine.Engine, version version.Version, w http.ResponseWrit
job = eng.Job("commit", r.Form.Get("container"))
stdoutBuffer = bytes.NewBuffer(nil)
)
if err := checkForJson(r); err != nil {
return err
}
if err := config.Decode(r.Body); err != nil {
log.Errorf("%s", err)
}
@@ -611,10 +635,18 @@ func getImagesGet(eng *engine.Engine, version version.Version, w http.ResponseWr
if vars == nil {
return fmt.Errorf("Missing parameter")
}
if err := parseForm(r); err != nil {
return err
}
if version.GreaterThan("1.0") {
w.Header().Set("Content-Type", "application/x-tar")
}
job := eng.Job("image_export", vars["name"])
var job *engine.Job
if name, ok := vars["name"]; ok {
job = eng.Job("image_export", name)
} else {
job = eng.Job("image_export", r.Form["names"]...)
}
job.Stdout.Add(w)
return job.Run()
}
@@ -636,6 +668,11 @@ func postContainersCreate(eng *engine.Engine, version version.Version, w http.Re
stdoutBuffer = bytes.NewBuffer(nil)
warnings = bytes.NewBuffer(nil)
)
if err := checkForJson(r); err != nil {
return err
}
if err := job.DecodeEnv(r.Body); err != nil {
return err
}
@@ -653,6 +690,7 @@ func postContainersCreate(eng *engine.Engine, version version.Version, w http.Re
}
out.Set("Id", engine.Tail(stdoutBuffer, 1))
out.SetList("Warnings", outWarnings)
return writeJSON(w, http.StatusCreated, out)
}
@@ -679,7 +717,7 @@ func deleteContainers(eng *engine.Engine, version version.Version, w http.Respon
if vars == nil {
return fmt.Errorf("Missing parameter")
}
job := eng.Job("delete", vars["name"])
job := eng.Job("rm", vars["name"])
job.Setenv("forceRemove", r.Form.Get("force"))
@@ -716,10 +754,15 @@ func postContainersStart(eng *engine.Engine, version version.Version, w http.Res
job = eng.Job("start", name)
)
// If contentLength is -1, we can assumed chunked encoding
// or more technically that the length is unknown
// http://golang.org/src/pkg/net/http/request.go#L139
// net/http otherwise seems to swallow any headers related to chunked encoding
// including r.TransferEncoding
// allow a nil body for backwards compatibility
if r.Body != nil && r.ContentLength > 0 {
if !api.MatchesContentType(r.Header.Get("Content-Type"), "application/json") {
return fmt.Errorf("Content-Type of application/json is required")
if r.Body != nil && (r.ContentLength > 0 || r.ContentLength == -1) {
if err := checkForJson(r); err != nil {
return err
}
if err := job.DecodeEnv(r.Body); err != nil {
@@ -832,8 +875,8 @@ func postContainersAttach(eng *engine.Engine, version version.Version, w http.Re
fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
if c.GetSubEnv("Config") != nil && !c.GetSubEnv("Config").GetBool("Tty") && version.GreaterThanOrEqualTo("1.6") {
errStream = utils.NewStdWriter(outStream, utils.Stderr)
outStream = utils.NewStdWriter(outStream, utils.Stdout)
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
} else {
errStream = outStream
}
@@ -984,12 +1027,12 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp
var copyData engine.Env
if contentType := r.Header.Get("Content-Type"); api.MatchesContentType(contentType, "application/json") {
if err := copyData.Decode(r.Body); err != nil {
return err
}
} else {
return fmt.Errorf("Content-Type not supported: %s", contentType)
if err := checkForJson(r); err != nil {
return err
}
if err := copyData.Decode(r.Body); err != nil {
return err
}
if copyData.Get("Resource") == "" {
@@ -1004,6 +1047,7 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp
job := eng.Job("container_copy", vars["name"], copyData.Get("Resource"))
job.Stdout.Add(w)
w.Header().Set("Content-Type", "application/x-tar")
if err := job.Run(); err != nil {
log.Errorf("%s", err.Error())
if strings.Contains(err.Error(), "No such container") {
@@ -1015,6 +1059,107 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp
return nil
}
func postContainerExecCreate(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return nil
}
var (
out engine.Env
name = vars["name"]
job = eng.Job("execCreate", name)
stdoutBuffer = bytes.NewBuffer(nil)
)
if err := job.DecodeEnv(r.Body); err != nil {
return err
}
job.Stdout.Add(stdoutBuffer)
// Register an instance of Exec in container.
if err := job.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error setting up exec command in container %s: %s\n", name, err)
return err
}
// Return the ID
out.Set("Id", engine.Tail(stdoutBuffer, 1))
return writeJSON(w, http.StatusCreated, out)
}
// TODO(vishh): Refactor the code to avoid having to specify stream config as part of both create and start.
func postContainerExecStart(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return nil
}
var (
name = vars["name"]
job = eng.Job("execStart", name)
errOut io.Writer = os.Stderr
)
if err := job.DecodeEnv(r.Body); err != nil {
return err
}
if !job.GetenvBool("Detach") {
// Setting up the streaming http interface.
inStream, outStream, err := hijackServer(w)
if err != nil {
return err
}
defer func() {
if tcpc, ok := inStream.(*net.TCPConn); ok {
tcpc.CloseWrite()
} else {
inStream.Close()
}
}()
defer func() {
if tcpc, ok := outStream.(*net.TCPConn); ok {
tcpc.CloseWrite()
} else if closer, ok := outStream.(io.Closer); ok {
closer.Close()
}
}()
var errStream io.Writer
fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
if !job.GetenvBool("Tty") && version.GreaterThanOrEqualTo("1.6") {
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
} else {
errStream = outStream
}
job.Stdin.Add(inStream)
job.Stdout.Add(outStream)
job.Stderr.Set(errStream)
errOut = outStream
}
// Now run the user process in container.
job.SetCloseIO(false)
if err := job.Run(); err != nil {
fmt.Fprintf(errOut, "Error starting exec command in container %s: %s\n", name, err)
return err
}
w.WriteHeader(http.StatusNoContent)
return nil
}
func postContainerExecResize(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return err
}
if vars == nil {
return fmt.Errorf("Missing parameter")
}
if err := eng.Job("execResize", vars["name"], r.Form.Get("h"), r.Form.Get("w")).Run(); err != nil {
return err
}
return nil
}
func optionsHandler(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
w.WriteHeader(http.StatusOK)
return nil
@@ -1105,6 +1250,7 @@ func createRouter(eng *engine.Engine, logging, enableCors bool, dockerVersion st
"/images/json": getImagesJSON,
"/images/viz": getImagesViz,
"/images/search": getImagesSearch,
"/images/get": getImagesGet,
"/images/{name:.*}/get": getImagesGet,
"/images/{name:.*}/history": getImagesHistory,
"/images/{name:.*}/json": getImagesByName,
@@ -1136,6 +1282,9 @@ func createRouter(eng *engine.Engine, logging, enableCors bool, dockerVersion st
"/containers/{name:.*}/resize": postContainersResize,
"/containers/{name:.*}/attach": postContainersAttach,
"/containers/{name:.*}/copy": postContainersCopy,
"/containers/{name:.*}/exec": postContainerExecCreate,
"/exec/{name:.*}/start": postContainerExecStart,
"/exec/{name:.*}/resize": postContainerExecResize,
},
"DELETE": {
"/containers/{name:.*}": deleteContainers,
@@ -1209,7 +1358,7 @@ func ServeFd(addr string, handle http.Handler) error {
}()
}
for i := 0; i < len(ls); i += 1 {
for i := 0; i < len(ls); i++ {
err := <-chErrors
if err != nil {
return err
@@ -1290,6 +1439,8 @@ func ListenAndServe(proto, addr string, job *engine.Job) error {
tlsConfig := &tls.Config{
NextProtos: []string{"http/1.1"},
Certificates: []tls.Certificate{cert},
// Avoid fallback on insecure SSL protocols
MinVersion: tls.VersionTLS10,
}
if job.GetenvBool("TlsVerify") {
certPool := x509.NewCertPool()
@@ -1322,6 +1473,7 @@ func ListenAndServe(proto, addr string, job *engine.Job) error {
return err
}
}
}
if err := os.Chmod(addr, 0660); err != nil {
return err
@@ -1357,7 +1509,7 @@ func ServeApi(job *engine.Job) engine.Status {
}()
}
for i := 0; i < len(protoAddrs); i += 1 {
for i := 0; i < len(protoAddrs); i++ {
err := <-chErrors
if err != nil {
return job.Error(err)

View File

@@ -455,7 +455,7 @@ func TestDeleteContainers(t *testing.T) {
eng := engine.New()
name := "foo"
var called bool
eng.Register("delete", func(job *engine.Job) engine.Status {
eng.Register("rm", func(job *engine.Job) engine.Status {
called = true
if len(job.Args) == 0 {
t.Fatalf("Job arguments is empty")

View File

@@ -1,3 +0,0 @@
This code provides helper functions for dealing with archive files.
**TODO**: Move this to either `pkg` or (if not possible) to `utils`.

View File

@@ -1,4 +0,0 @@
package archive
const twBufSize = 32 * 1024
const trBufSize = 32 * 1024

2
builder/MAINTAINERS Normal file
View File

@@ -0,0 +1,2 @@
Tibor Vass <teabee89@gmail.com> (@tiborvass)
Erik Hollensbe <github@hollensbe.org> (@erikh)

353
builder/dispatchers.go Normal file
View File

@@ -0,0 +1,353 @@
package builder
// This file contains the dispatchers for each command. Note that
// `nullDispatch` is not actually a command, but support for commands we parse
// but do nothing with.
//
// See evaluator.go for a higher level discussion of the whole evaluator
// package.
import (
"fmt"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"github.com/docker/docker/nat"
"github.com/docker/docker/pkg/log"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/runconfig"
)
// dispatch with no layer / parsing. This is effectively not a command.
func nullDispatch(b *Builder, args []string, attributes map[string]bool, original string) error {
return nil
}
// ENV foo bar
//
// Sets the environment variable foo to bar, also makes interpolation
// in the dockerfile available from the next statement on via ${foo}.
//
func env(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) != 2 {
return fmt.Errorf("ENV accepts two arguments")
}
fullEnv := fmt.Sprintf("%s=%s", args[0], args[1])
for i, envVar := range b.Config.Env {
envParts := strings.SplitN(envVar, "=", 2)
if args[0] == envParts[0] {
b.Config.Env[i] = fullEnv
return b.commit("", b.Config.Cmd, fmt.Sprintf("ENV %s", fullEnv))
}
}
b.Config.Env = append(b.Config.Env, fullEnv)
return b.commit("", b.Config.Cmd, fmt.Sprintf("ENV %s", fullEnv))
}
// MAINTAINER some text <maybe@an.email.address>
//
// Sets the maintainer metadata.
func maintainer(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) != 1 {
return fmt.Errorf("MAINTAINER requires only one argument")
}
b.maintainer = args[0]
return b.commit("", b.Config.Cmd, fmt.Sprintf("MAINTAINER %s", b.maintainer))
}
// ADD foo /path
//
// Add the file 'foo' to '/path'. Tarball and Remote URL (git, http) handling
// exist here. If you do not wish to have this automatic handling, use COPY.
//
func add(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) < 2 {
return fmt.Errorf("ADD requires at least two arguments")
}
return b.runContextCommand(args, true, true, "ADD")
}
// COPY foo /path
//
// Same as 'ADD' but without the tar and remote url handling.
//
func dispatchCopy(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) < 2 {
return fmt.Errorf("COPY requires at least two arguments")
}
return b.runContextCommand(args, false, false, "COPY")
}
// FROM imagename
//
// This sets the image the dockerfile will build on top of.
//
func from(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) != 1 {
return fmt.Errorf("FROM requires one argument")
}
name := args[0]
image, err := b.Daemon.Repositories().LookupImage(name)
if err != nil {
if b.Daemon.Graph().IsNotExist(err) {
image, err = b.pullImage(name)
}
// note that the top level err will still be !nil here if IsNotExist is
// not the error. This approach just simplifies hte logic a bit.
if err != nil {
return err
}
}
return b.processImageFrom(image)
}
// ONBUILD RUN echo yo
//
// ONBUILD triggers run when the image is used in a FROM statement.
//
// ONBUILD handling has a lot of special-case functionality, the heading in
// evaluator.go and comments around dispatch() in the same file explain the
// special cases. search for 'OnBuild' in internals.go for additional special
// cases.
//
func onbuild(b *Builder, args []string, attributes map[string]bool, original string) error {
triggerInstruction := strings.ToUpper(strings.TrimSpace(args[0]))
switch triggerInstruction {
case "ONBUILD":
return fmt.Errorf("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed")
case "MAINTAINER", "FROM":
return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction)
}
original = regexp.MustCompile(`(?i)^\s*ONBUILD\s*`).ReplaceAllString(original, "")
b.Config.OnBuild = append(b.Config.OnBuild, original)
return b.commit("", b.Config.Cmd, fmt.Sprintf("ONBUILD %s", original))
}
// WORKDIR /tmp
//
// Set the working directory for future RUN/CMD/etc statements.
//
func workdir(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) != 1 {
return fmt.Errorf("WORKDIR requires exactly one argument")
}
workdir := args[0]
if workdir[0] == '/' {
b.Config.WorkingDir = workdir
} else {
if b.Config.WorkingDir == "" {
b.Config.WorkingDir = "/"
}
b.Config.WorkingDir = filepath.Join(b.Config.WorkingDir, workdir)
}
return b.commit("", b.Config.Cmd, fmt.Sprintf("WORKDIR %v", workdir))
}
// RUN some command yo
//
// run a command and commit the image. Args are automatically prepended with
// 'sh -c' in the event there is only one argument. The difference in
// processing:
//
// RUN echo hi # sh -c echo hi
// RUN [ "echo", "hi" ] # echo hi
//
func run(b *Builder, args []string, attributes map[string]bool, original string) error {
if b.image == "" {
return fmt.Errorf("Please provide a source image with `from` prior to run")
}
args = handleJsonArgs(args, attributes)
if len(args) == 1 {
args = append([]string{"/bin/sh", "-c"}, args[0])
}
runCmd := flag.NewFlagSet("run", flag.ContinueOnError)
runCmd.SetOutput(ioutil.Discard)
runCmd.Usage = nil
config, _, _, err := runconfig.Parse(runCmd, append([]string{b.image}, args...), nil)
if err != nil {
return err
}
cmd := b.Config.Cmd
// set Cmd manually, this is special case only for Dockerfiles
b.Config.Cmd = config.Cmd
runconfig.Merge(b.Config, config)
defer func(cmd []string) { b.Config.Cmd = cmd }(cmd)
log.Debugf("[BUILDER] Command to be executed: %v", b.Config.Cmd)
hit, err := b.probeCache()
if err != nil {
return err
}
if hit {
return nil
}
c, err := b.create()
if err != nil {
return err
}
// Ensure that we keep the container mounted until the commit
// to avoid unmounting and then mounting directly again
c.Mount()
defer c.Unmount()
err = b.run(c)
if err != nil {
return err
}
if err := b.commit(c.ID, cmd, "run"); err != nil {
return err
}
return nil
}
// CMD foo
//
// Set the default command to run in the container (which may be empty).
// Argument handling is the same as RUN.
//
func cmd(b *Builder, args []string, attributes map[string]bool, original string) error {
b.Config.Cmd = handleJsonArgs(args, attributes)
if !attributes["json"] {
b.Config.Cmd = append([]string{"/bin/sh", "-c"}, b.Config.Cmd...)
}
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("CMD %v", b.Config.Cmd)); err != nil {
return err
}
if len(args) != 0 {
b.cmdSet = true
}
return nil
}
// ENTRYPOINT /usr/sbin/nginx
//
// Set the entrypoint (which defaults to sh -c) to /usr/sbin/nginx. Will
// accept the CMD as the arguments to /usr/sbin/nginx.
//
// Handles command processing similar to CMD and RUN, only b.Config.Entrypoint
// is initialized at NewBuilder time instead of through argument parsing.
//
func entrypoint(b *Builder, args []string, attributes map[string]bool, original string) error {
parsed := handleJsonArgs(args, attributes)
switch {
case attributes["json"]:
// ENTRYPOINT ["echo", "hi"]
b.Config.Entrypoint = parsed
case len(parsed) == 0:
// ENTRYPOINT []
b.Config.Entrypoint = nil
default:
// ENTRYPOINT echo hi
b.Config.Entrypoint = []string{"/bin/sh", "-c", parsed[0]}
}
// when setting the entrypoint if a CMD was not explicitly set then
// set the command to nil
if !b.cmdSet {
b.Config.Cmd = nil
}
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("ENTRYPOINT %v", b.Config.Entrypoint)); err != nil {
return err
}
return nil
}
// EXPOSE 6667/tcp 7000/tcp
//
// Expose ports for links and port mappings. This all ends up in
// b.Config.ExposedPorts for runconfig.
//
func expose(b *Builder, args []string, attributes map[string]bool, original string) error {
portsTab := args
if b.Config.ExposedPorts == nil {
b.Config.ExposedPorts = make(nat.PortSet)
}
ports, _, err := nat.ParsePortSpecs(append(portsTab, b.Config.PortSpecs...))
if err != nil {
return err
}
for port := range ports {
if _, exists := b.Config.ExposedPorts[port]; !exists {
b.Config.ExposedPorts[port] = struct{}{}
}
}
b.Config.PortSpecs = nil
return b.commit("", b.Config.Cmd, fmt.Sprintf("EXPOSE %v", ports))
}
// USER foo
//
// Set the user to 'foo' for future commands and when running the
// ENTRYPOINT/CMD at container run time.
//
func user(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) != 1 {
return fmt.Errorf("USER requires exactly one argument")
}
b.Config.User = args[0]
return b.commit("", b.Config.Cmd, fmt.Sprintf("USER %v", args))
}
// VOLUME /foo
//
// Expose the volume /foo for use. Will also accept the JSON array form.
//
func volume(b *Builder, args []string, attributes map[string]bool, original string) error {
if len(args) == 0 {
return fmt.Errorf("Volume cannot be empty")
}
if b.Config.Volumes == nil {
b.Config.Volumes = map[string]struct{}{}
}
for _, v := range args {
b.Config.Volumes[v] = struct{}{}
}
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("VOLUME %v", args)); err != nil {
return err
}
return nil
}
// INSERT is no longer accepted, but we still parse it.
func insert(b *Builder, args []string, attributes map[string]bool, original string) error {
return fmt.Errorf("INSERT has been deprecated. Please use ADD instead")
}

236
builder/evaluator.go Normal file
View File

@@ -0,0 +1,236 @@
// builder is the evaluation step in the Dockerfile parse/evaluate pipeline.
//
// It incorporates a dispatch table based on the parser.Node values (see the
// parser package for more information) that are yielded from the parser itself.
// Calling NewBuilder with the BuildOpts struct can be used to customize the
// experience for execution purposes only. Parsing is controlled in the parser
// package, and this division of resposibility should be respected.
//
// Please see the jump table targets for the actual invocations, most of which
// will call out to the functions in internals.go to deal with their tasks.
//
// ONBUILD is a special case, which is covered in the onbuild() func in
// dispatchers.go.
//
// The evaluator uses the concept of "steps", which are usually each processable
// line in the Dockerfile. Each step is numbered and certain actions are taken
// before and after each step, such as creating an image ID and removing temporary
// containers and images. Note that ONBUILD creates a kinda-sorta "sub run" which
// includes its own set of steps (usually only one of them).
package builder
import (
"errors"
"fmt"
"io"
"os"
"path"
"strings"
"github.com/docker/docker/builder/parser"
"github.com/docker/docker/daemon"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/tarsum"
"github.com/docker/docker/registry"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/utils"
)
var (
ErrDockerfileEmpty = errors.New("Dockerfile cannot be empty")
)
// Environment variable interpolation will happen on these statements only.
var replaceEnvAllowed = map[string]struct{}{
"env": {},
"add": {},
"copy": {},
"workdir": {},
"expose": {},
"volume": {},
"user": {},
}
var evaluateTable map[string]func(*Builder, []string, map[string]bool, string) error
func init() {
evaluateTable = map[string]func(*Builder, []string, map[string]bool, string) error{
"env": env,
"maintainer": maintainer,
"add": add,
"copy": dispatchCopy, // copy() is a go builtin
"from": from,
"onbuild": onbuild,
"workdir": workdir,
"run": run,
"cmd": cmd,
"entrypoint": entrypoint,
"expose": expose,
"volume": volume,
"user": user,
"insert": insert,
}
}
// internal struct, used to maintain configuration of the Dockerfile's
// processing as it evaluates the parsing result.
type Builder struct {
Daemon *daemon.Daemon
Engine *engine.Engine
// effectively stdio for the run. Because it is not stdio, I said
// "Effectively". Do not use stdio anywhere in this package for any reason.
OutStream io.Writer
ErrStream io.Writer
Verbose bool
UtilizeCache bool
// controls how images and containers are handled between steps.
Remove bool
ForceRemove bool
AuthConfig *registry.AuthConfig
AuthConfigFile *registry.ConfigFile
// Deprecated, original writer used for ImagePull. To be removed.
OutOld io.Writer
StreamFormatter *utils.StreamFormatter
Config *runconfig.Config // runconfig for cmd, run, entrypoint etc.
// both of these are controlled by the Remove and ForceRemove options in BuildOpts
TmpContainers map[string]struct{} // a map of containers used for removes
dockerfile *parser.Node // the syntax tree of the dockerfile
image string // image name for commit processing
maintainer string // maintainer name. could probably be removed.
cmdSet bool // indicates is CMD was set in current Dockerfile
context tarsum.TarSum // the context is a tarball that is uploaded by the client
contextPath string // the path of the temporary directory the local context is unpacked to (server side)
}
// Run the builder with the context. This is the lynchpin of this package. This
// will (barring errors):
//
// * call readContext() which will set up the temporary directory and unpack
// the context into it.
// * read the dockerfile
// * parse the dockerfile
// * walk the parse tree and execute it by dispatching to handlers. If Remove
// or ForceRemove is set, additional cleanup around containers happens after
// processing.
// * Print a happy message and return the image ID.
//
func (b *Builder) Run(context io.Reader) (string, error) {
if err := b.readContext(context); err != nil {
return "", err
}
defer func() {
if err := os.RemoveAll(b.contextPath); err != nil {
log.Debugf("[BUILDER] failed to remove temporary context: %s", err)
}
}()
filename := path.Join(b.contextPath, "Dockerfile")
fi, err := os.Stat(filename)
if os.IsNotExist(err) {
return "", fmt.Errorf("Cannot build a directory without a Dockerfile")
}
if fi.Size() == 0 {
return "", ErrDockerfileEmpty
}
f, err := os.Open(filename)
if err != nil {
return "", err
}
defer f.Close()
ast, err := parser.Parse(f)
if err != nil {
return "", err
}
b.dockerfile = ast
// some initializations that would not have been supplied by the caller.
b.Config = &runconfig.Config{}
b.TmpContainers = map[string]struct{}{}
for i, n := range b.dockerfile.Children {
if err := b.dispatch(i, n); err != nil {
if b.ForceRemove {
b.clearTmp()
}
return "", err
}
fmt.Fprintf(b.OutStream, " ---> %s\n", utils.TruncateID(b.image))
if b.Remove {
b.clearTmp()
}
}
if b.image == "" {
return "", fmt.Errorf("No image was generated. Is your Dockerfile empty?\n")
}
fmt.Fprintf(b.OutStream, "Successfully built %s\n", utils.TruncateID(b.image))
return b.image, nil
}
// This method is the entrypoint to all statement handling routines.
//
// Almost all nodes will have this structure:
// Child[Node, Node, Node] where Child is from parser.Node.Children and each
// node comes from parser.Node.Next. This forms a "line" with a statement and
// arguments and we process them in this normalized form by hitting
// evaluateTable with the leaf nodes of the command and the Builder object.
//
// ONBUILD is a special case; in this case the parser will emit:
// Child[Node, Child[Node, Node...]] where the first node is the literal
// "onbuild" and the child entrypoint is the command of the ONBUILD statmeent,
// such as `RUN` in ONBUILD RUN foo. There is special case logic in here to
// deal with that, at least until it becomes more of a general concern with new
// features.
func (b *Builder) dispatch(stepN int, ast *parser.Node) error {
cmd := ast.Value
attrs := ast.Attributes
original := ast.Original
strs := []string{}
msg := fmt.Sprintf("Step %d : %s", stepN, strings.ToUpper(cmd))
if cmd == "onbuild" {
ast = ast.Next.Children[0]
strs = append(strs, ast.Value)
msg += " " + ast.Value
}
for ast.Next != nil {
ast = ast.Next
var str string
str = ast.Value
if _, ok := replaceEnvAllowed[cmd]; ok {
str = b.replaceEnv(ast.Value)
}
strs = append(strs, str)
msg += " " + ast.Value
}
fmt.Fprintln(b.OutStream, msg)
// XXX yes, we skip any cmds that are not valid; the parser should have
// picked these out already.
if f, ok := evaluateTable[cmd]; ok {
return f(b, strs, attrs, original)
}
fmt.Fprintf(b.ErrStream, "# Skipping unknown instruction %s\n", strings.ToUpper(cmd))
return nil
}

689
builder/internals.go Normal file
View File

@@ -0,0 +1,689 @@
package builder
// internals for handling commands. Covers many areas and a lot of
// non-contiguous functionality. Please read the comments.
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"path"
"path/filepath"
"sort"
"strings"
"syscall"
"time"
"github.com/docker/docker/builder/parser"
"github.com/docker/docker/daemon"
imagepkg "github.com/docker/docker/image"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/chrootarchive"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/pkg/symlink"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/pkg/tarsum"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
)
func (b *Builder) readContext(context io.Reader) error {
tmpdirPath, err := ioutil.TempDir("", "docker-build")
if err != nil {
return err
}
decompressedStream, err := archive.DecompressStream(context)
if err != nil {
return err
}
if b.context, err = tarsum.NewTarSum(decompressedStream, true, tarsum.Version0); err != nil {
return err
}
if err := chrootarchive.Untar(b.context, tmpdirPath, nil); err != nil {
return err
}
b.contextPath = tmpdirPath
return nil
}
func (b *Builder) commit(id string, autoCmd []string, comment string) error {
if b.image == "" {
return fmt.Errorf("Please provide a source image with `from` prior to commit")
}
b.Config.Image = b.image
if id == "" {
cmd := b.Config.Cmd
b.Config.Cmd = []string{"/bin/sh", "-c", "#(nop) " + comment}
defer func(cmd []string) { b.Config.Cmd = cmd }(cmd)
hit, err := b.probeCache()
if err != nil {
return err
}
if hit {
return nil
}
container, err := b.create()
if err != nil {
return err
}
id = container.ID
if err := container.Mount(); err != nil {
return err
}
defer container.Unmount()
}
container := b.Daemon.Get(id)
if container == nil {
return fmt.Errorf("An error occured while creating the container")
}
// Note: Actually copy the struct
autoConfig := *b.Config
autoConfig.Cmd = autoCmd
// Commit the container
image, err := b.Daemon.Commit(container, "", "", "", b.maintainer, true, &autoConfig)
if err != nil {
return err
}
b.image = image.ID
return nil
}
type copyInfo struct {
origPath string
destPath string
hash string
decompress bool
tmpDir string
}
func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecompression bool, cmdName string) error {
if b.context == nil {
return fmt.Errorf("No context given. Impossible to use %s", cmdName)
}
if len(args) < 2 {
return fmt.Errorf("Invalid %s format - at least two arguments required", cmdName)
}
dest := args[len(args)-1] // last one is always the dest
copyInfos := []*copyInfo{}
b.Config.Image = b.image
defer func() {
for _, ci := range copyInfos {
if ci.tmpDir != "" {
os.RemoveAll(ci.tmpDir)
}
}
}()
// Loop through each src file and calculate the info we need to
// do the copy (e.g. hash value if cached). Don't actually do
// the copy until we've looked at all src files
for _, orig := range args[0 : len(args)-1] {
err := calcCopyInfo(b, cmdName, &copyInfos, orig, dest, allowRemote, allowDecompression)
if err != nil {
return err
}
}
if len(copyInfos) == 0 {
return fmt.Errorf("No source files were specified")
}
if len(copyInfos) > 1 && !strings.HasSuffix(dest, "/") {
return fmt.Errorf("When using %s with more than one source file, the destination must be a directory and end with a /", cmdName)
}
// For backwards compat, if there's just one CI then use it as the
// cache look-up string, otherwise hash 'em all into one
var srcHash string
var origPaths string
if len(copyInfos) == 1 {
srcHash = copyInfos[0].hash
origPaths = copyInfos[0].origPath
} else {
var hashs []string
var origs []string
for _, ci := range copyInfos {
hashs = append(hashs, ci.hash)
origs = append(origs, ci.origPath)
}
hasher := sha256.New()
hasher.Write([]byte(strings.Join(hashs, ",")))
srcHash = "multi:" + hex.EncodeToString(hasher.Sum(nil))
origPaths = strings.Join(origs, " ")
}
cmd := b.Config.Cmd
b.Config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest)}
defer func(cmd []string) { b.Config.Cmd = cmd }(cmd)
hit, err := b.probeCache()
if err != nil {
return err
}
// If we do not have at least one hash, never use the cache
if hit && b.UtilizeCache {
return nil
}
container, _, err := b.Daemon.Create(b.Config, nil, "")
if err != nil {
return err
}
b.TmpContainers[container.ID] = struct{}{}
if err := container.Mount(); err != nil {
return err
}
defer container.Unmount()
for _, ci := range copyInfos {
if err := b.addContext(container, ci.origPath, ci.destPath, ci.decompress); err != nil {
return err
}
}
if err := b.commit(container.ID, cmd, fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest)); err != nil {
return err
}
return nil
}
func calcCopyInfo(b *Builder, cmdName string, cInfos *[]*copyInfo, origPath string, destPath string, allowRemote bool, allowDecompression bool) error {
if origPath != "" && origPath[0] == '/' && len(origPath) > 1 {
origPath = origPath[1:]
}
origPath = strings.TrimPrefix(origPath, "./")
// In the remote/URL case, download it and gen its hashcode
if utils.IsURL(origPath) {
if !allowRemote {
return fmt.Errorf("Source can't be a URL for %s", cmdName)
}
ci := copyInfo{}
ci.origPath = origPath
ci.hash = origPath // default to this but can change
ci.destPath = destPath
ci.decompress = false
*cInfos = append(*cInfos, &ci)
// Initiate the download
resp, err := utils.Download(ci.origPath)
if err != nil {
return err
}
// Create a tmp dir
tmpDirName, err := ioutil.TempDir(b.contextPath, "docker-remote")
if err != nil {
return err
}
ci.tmpDir = tmpDirName
// Create a tmp file within our tmp dir
tmpFileName := path.Join(tmpDirName, "tmp")
tmpFile, err := os.OpenFile(tmpFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
return err
}
// Download and dump result to tmp file
if _, err := io.Copy(tmpFile, utils.ProgressReader(resp.Body, int(resp.ContentLength), b.OutOld, b.StreamFormatter, true, "", "Downloading")); err != nil {
tmpFile.Close()
return err
}
fmt.Fprintf(b.OutStream, "\n")
tmpFile.Close()
// Remove the mtime of the newly created tmp file
if err := system.UtimesNano(tmpFileName, make([]syscall.Timespec, 2)); err != nil {
return err
}
ci.origPath = path.Join(filepath.Base(tmpDirName), filepath.Base(tmpFileName))
// If the destination is a directory, figure out the filename.
if strings.HasSuffix(ci.destPath, "/") {
u, err := url.Parse(origPath)
if err != nil {
return err
}
path := u.Path
if strings.HasSuffix(path, "/") {
path = path[:len(path)-1]
}
parts := strings.Split(path, "/")
filename := parts[len(parts)-1]
if filename == "" {
return fmt.Errorf("cannot determine filename from url: %s", u)
}
ci.destPath = ci.destPath + filename
}
// Calc the checksum, only if we're using the cache
if b.UtilizeCache {
r, err := archive.Tar(tmpFileName, archive.Uncompressed)
if err != nil {
return err
}
tarSum, err := tarsum.NewTarSum(r, true, tarsum.Version0)
if err != nil {
return err
}
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
return err
}
ci.hash = tarSum.Sum(nil)
r.Close()
}
return nil
}
// Deal with wildcards
if ContainsWildcards(origPath) {
for _, fileInfo := range b.context.GetSums() {
if fileInfo.Name() == "" {
continue
}
match, _ := path.Match(origPath, fileInfo.Name())
if !match {
continue
}
calcCopyInfo(b, cmdName, cInfos, fileInfo.Name(), destPath, allowRemote, allowDecompression)
}
return nil
}
// Must be a dir or a file
if err := b.checkPathForAddition(origPath); err != nil {
return err
}
fi, _ := os.Stat(path.Join(b.contextPath, origPath))
ci := copyInfo{}
ci.origPath = origPath
ci.hash = origPath
ci.destPath = destPath
ci.decompress = allowDecompression
*cInfos = append(*cInfos, &ci)
// If not using cache don't need to do anything else.
// If we are using a cache then calc the hash for the src file/dir
if !b.UtilizeCache {
return nil
}
// Deal with the single file case
if !fi.IsDir() {
// This will match first file in sums of the archive
fis := b.context.GetSums().GetFile(ci.origPath)
if fis != nil {
ci.hash = "file:" + fis.Sum()
}
return nil
}
// Must be a dir
var subfiles []string
absOrigPath := path.Join(b.contextPath, ci.origPath)
// Add a trailing / to make sure we only pick up nested files under
// the dir and not sibling files of the dir that just happen to
// start with the same chars
if !strings.HasSuffix(absOrigPath, "/") {
absOrigPath += "/"
}
// Need path w/o / too to find matching dir w/o trailing /
absOrigPathNoSlash := absOrigPath[:len(absOrigPath)-1]
for _, fileInfo := range b.context.GetSums() {
absFile := path.Join(b.contextPath, fileInfo.Name())
if strings.HasPrefix(absFile, absOrigPath) || absFile == absOrigPathNoSlash {
subfiles = append(subfiles, fileInfo.Sum())
}
}
sort.Strings(subfiles)
hasher := sha256.New()
hasher.Write([]byte(strings.Join(subfiles, ",")))
ci.hash = "dir:" + hex.EncodeToString(hasher.Sum(nil))
return nil
}
func ContainsWildcards(name string) bool {
for i := 0; i < len(name); i++ {
ch := name[i]
if ch == '\\' {
i++
} else if ch == '*' || ch == '?' || ch == '[' {
return true
}
}
return false
}
func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
remote, tag := parsers.ParseRepositoryTag(name)
if tag == "" {
tag = "latest"
}
pullRegistryAuth := b.AuthConfig
if len(b.AuthConfigFile.Configs) > 0 {
// The request came with a full auth config file, we prefer to use that
endpoint, _, err := registry.ResolveRepositoryName(remote)
if err != nil {
return nil, err
}
resolvedAuth := b.AuthConfigFile.ResolveAuthConfig(endpoint)
pullRegistryAuth = &resolvedAuth
}
job := b.Engine.Job("pull", remote, tag)
job.SetenvBool("json", b.StreamFormatter.Json())
job.SetenvBool("parallel", true)
job.SetenvJson("authConfig", pullRegistryAuth)
job.Stdout.Add(b.OutOld)
if err := job.Run(); err != nil {
return nil, err
}
image, err := b.Daemon.Repositories().LookupImage(name)
if err != nil {
return nil, err
}
return image, nil
}
func (b *Builder) processImageFrom(img *imagepkg.Image) error {
b.image = img.ID
if img.Config != nil {
b.Config = img.Config
}
if len(b.Config.Env) == 0 {
b.Config.Env = append(b.Config.Env, "PATH="+daemon.DefaultPathEnv)
}
// Process ONBUILD triggers if they exist
if nTriggers := len(b.Config.OnBuild); nTriggers != 0 {
fmt.Fprintf(b.ErrStream, "# Executing %d build triggers\n", nTriggers)
}
// Copy the ONBUILD triggers, and remove them from the config, since the config will be commited.
onBuildTriggers := b.Config.OnBuild
b.Config.OnBuild = []string{}
// parse the ONBUILD triggers by invoking the parser
for stepN, step := range onBuildTriggers {
ast, err := parser.Parse(strings.NewReader(step))
if err != nil {
return err
}
for i, n := range ast.Children {
switch strings.ToUpper(n.Value) {
case "ONBUILD":
return fmt.Errorf("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed")
case "MAINTAINER", "FROM":
return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", n.Value)
}
fmt.Fprintf(b.OutStream, "Trigger %d, %s\n", stepN, step)
if err := b.dispatch(i, n); err != nil {
return err
}
}
}
return nil
}
// probeCache checks to see if image-caching is enabled (`b.UtilizeCache`)
// and if so attempts to look up the current `b.image` and `b.Config` pair
// in the current server `b.Daemon`. If an image is found, probeCache returns
// `(true, nil)`. If no image is found, it returns `(false, nil)`. If there
// is any error, it returns `(false, err)`.
func (b *Builder) probeCache() (bool, error) {
if b.UtilizeCache {
if cache, err := b.Daemon.ImageGetCached(b.image, b.Config); err != nil {
return false, err
} else if cache != nil {
fmt.Fprintf(b.OutStream, " ---> Using cache\n")
log.Debugf("[BUILDER] Use cached version")
b.image = cache.ID
return true, nil
} else {
log.Debugf("[BUILDER] Cache miss")
}
}
return false, nil
}
func (b *Builder) create() (*daemon.Container, error) {
if b.image == "" {
return nil, fmt.Errorf("Please provide a source image with `from` prior to run")
}
b.Config.Image = b.image
config := *b.Config
// Create the container
c, warnings, err := b.Daemon.Create(b.Config, nil, "")
if err != nil {
return nil, err
}
for _, warning := range warnings {
fmt.Fprintf(b.OutStream, " ---> [Warning] %s\n", warning)
}
b.TmpContainers[c.ID] = struct{}{}
fmt.Fprintf(b.OutStream, " ---> Running in %s\n", utils.TruncateID(c.ID))
// override the entry point that may have been picked up from the base image
c.Path = config.Cmd[0]
c.Args = config.Cmd[1:]
return c, nil
}
func (b *Builder) run(c *daemon.Container) error {
var errCh chan error
if b.Verbose {
errCh = promise.Go(func() error {
// FIXME: call the 'attach' job so that daemon.Attach can be made private
//
// FIXME (LK4D4): Also, maybe makes sense to call "logs" job, it is like attach
// but without hijacking for stdin. Also, with attach there can be race
// condition because of some output already was printed before it.
return <-b.Daemon.Attach(&c.StreamConfig, c.Config.OpenStdin, c.Config.StdinOnce, c.Config.Tty, nil, nil, b.OutStream, b.ErrStream)
})
}
//start the container
if err := c.Start(); err != nil {
return err
}
if errCh != nil {
if err := <-errCh; err != nil {
return err
}
}
// Wait for it to finish
if ret, _ := c.WaitStop(-1 * time.Second); ret != 0 {
err := &utils.JSONError{
Message: fmt.Sprintf("The command %v returned a non-zero code: %d", b.Config.Cmd, ret),
Code: ret,
}
return err
}
return nil
}
func (b *Builder) checkPathForAddition(orig string) error {
origPath := path.Join(b.contextPath, orig)
origPath, err := filepath.EvalSymlinks(origPath)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig)
}
return err
}
if !strings.HasPrefix(origPath, b.contextPath) {
return fmt.Errorf("Forbidden path outside the build context: %s (%s)", orig, origPath)
}
if _, err := os.Stat(origPath); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig)
}
return err
}
return nil
}
func (b *Builder) addContext(container *daemon.Container, orig, dest string, decompress bool) error {
var (
err error
destExists = true
origPath = path.Join(b.contextPath, orig)
destPath = path.Join(container.RootfsPath(), dest)
)
if destPath != container.RootfsPath() {
destPath, err = symlink.FollowSymlinkInScope(destPath, container.RootfsPath())
if err != nil {
return err
}
}
// Preserve the trailing '/'
if strings.HasSuffix(dest, "/") || dest == "." {
destPath = destPath + "/"
}
destStat, err := os.Stat(destPath)
if err != nil {
if !os.IsNotExist(err) {
return err
}
destExists = false
}
fi, err := os.Stat(origPath)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig)
}
return err
}
if fi.IsDir() {
return copyAsDirectory(origPath, destPath, destExists)
}
// If we are adding a remote file (or we've been told not to decompress), do not try to untar it
if decompress {
// First try to unpack the source as an archive
// to support the untar feature we need to clean up the path a little bit
// because tar is very forgiving. First we need to strip off the archive's
// filename from the path but this is only added if it does not end in / .
tarDest := destPath
if strings.HasSuffix(tarDest, "/") {
tarDest = filepath.Dir(destPath)
}
// try to successfully untar the orig
if err := chrootarchive.UntarPath(origPath, tarDest); err == nil {
return nil
} else if err != io.EOF {
log.Debugf("Couldn't untar %s to %s: %s", origPath, tarDest, err)
}
}
if err := os.MkdirAll(path.Dir(destPath), 0755); err != nil {
return err
}
if err := chrootarchive.CopyWithTar(origPath, destPath); err != nil {
return err
}
resPath := destPath
if destExists && destStat.IsDir() {
resPath = path.Join(destPath, path.Base(origPath))
}
return fixPermissions(resPath, 0, 0)
}
func copyAsDirectory(source, destination string, destinationExists bool) error {
if err := chrootarchive.CopyWithTar(source, destination); err != nil {
return err
}
if destinationExists {
files, err := ioutil.ReadDir(source)
if err != nil {
return err
}
for _, file := range files {
if err := fixPermissions(filepath.Join(destination, file.Name()), 0, 0); err != nil {
return err
}
}
return nil
}
return fixPermissions(destination, 0, 0)
}
func fixPermissions(destination string, uid, gid int) error {
return filepath.Walk(destination, func(path string, info os.FileInfo, err error) error {
if err := os.Lchown(path, uid, gid); err != nil && !os.IsNotExist(err) {
return err
}
return nil
})
}
func (b *Builder) clearTmp() {
for c := range b.TmpContainers {
tmp := b.Daemon.Get(c)
if err := b.Daemon.Destroy(tmp); err != nil {
fmt.Fprintf(b.OutStream, "Error removing intermediate container %s: %s\n", utils.TruncateID(c), err.Error())
return
}
b.Daemon.DeleteVolumes(tmp.VolumePaths())
delete(b.TmpContainers, c)
fmt.Fprintf(b.OutStream, "Removing intermediate container %s\n", utils.TruncateID(c))
}
}

130
builder/job.go Normal file
View File

@@ -0,0 +1,130 @@
package builder
import (
"io"
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/docker/docker/daemon"
"github.com/docker/docker/engine"
"github.com/docker/docker/graph"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
)
type BuilderJob struct {
Engine *engine.Engine
Daemon *daemon.Daemon
}
func (b *BuilderJob) Install() {
b.Engine.Register("build", b.CmdBuild)
}
func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
if len(job.Args) != 0 {
return job.Errorf("Usage: %s\n", job.Name)
}
var (
remoteURL = job.Getenv("remote")
repoName = job.Getenv("t")
suppressOutput = job.GetenvBool("q")
noCache = job.GetenvBool("nocache")
rm = job.GetenvBool("rm")
forceRm = job.GetenvBool("forcerm")
authConfig = &registry.AuthConfig{}
configFile = &registry.ConfigFile{}
tag string
context io.ReadCloser
)
job.GetenvJson("authConfig", authConfig)
job.GetenvJson("configFile", configFile)
repoName, tag = parsers.ParseRepositoryTag(repoName)
if repoName != "" {
if _, _, err := registry.ResolveRepositoryName(repoName); err != nil {
return job.Error(err)
}
if len(tag) > 0 {
if err := graph.ValidateTagName(tag); err != nil {
return job.Error(err)
}
}
}
if remoteURL == "" {
context = ioutil.NopCloser(job.Stdin)
} else if utils.IsGIT(remoteURL) {
if !strings.HasPrefix(remoteURL, "git://") {
remoteURL = "https://" + remoteURL
}
root, err := ioutil.TempDir("", "docker-build-git")
if err != nil {
return job.Error(err)
}
defer os.RemoveAll(root)
if output, err := exec.Command("git", "clone", "--recursive", remoteURL, root).CombinedOutput(); err != nil {
return job.Errorf("Error trying to use git: %s (%s)", err, output)
}
c, err := archive.Tar(root, archive.Uncompressed)
if err != nil {
return job.Error(err)
}
context = c
} else if utils.IsURL(remoteURL) {
f, err := utils.Download(remoteURL)
if err != nil {
return job.Error(err)
}
defer f.Body.Close()
dockerFile, err := ioutil.ReadAll(f.Body)
if err != nil {
return job.Error(err)
}
c, err := archive.Generate("Dockerfile", string(dockerFile))
if err != nil {
return job.Error(err)
}
context = c
}
defer context.Close()
sf := utils.NewStreamFormatter(job.GetenvBool("json"))
builder := &Builder{
Daemon: b.Daemon,
Engine: b.Engine,
OutStream: &utils.StdoutFormater{
Writer: job.Stdout,
StreamFormatter: sf,
},
ErrStream: &utils.StderrFormater{
Writer: job.Stdout,
StreamFormatter: sf,
},
Verbose: !suppressOutput,
UtilizeCache: !noCache,
Remove: rm,
ForceRemove: forceRm,
OutOld: job.Stdout,
StreamFormatter: sf,
AuthConfig: authConfig,
AuthConfigFile: configFile,
}
id, err := builder.Run(context)
if err != nil {
return job.Error(err)
}
if repoName != "" {
b.Daemon.Repositories().Set(repoName, tag, id, false)
}
return engine.StatusOK
}

View File

@@ -0,0 +1,32 @@
package main
import (
"fmt"
"os"
"github.com/docker/docker/builder/parser"
)
func main() {
var f *os.File
var err error
if len(os.Args) < 2 {
fmt.Println("please supply filename(s)")
os.Exit(1)
}
for _, fn := range os.Args[1:] {
f, err = os.Open(fn)
if err != nil {
panic(err)
}
ast, err := parser.Parse(f)
if err != nil {
panic(err)
} else {
fmt.Println(ast.Dump())
}
}
}

View File

@@ -0,0 +1,155 @@
package parser
// line parsers are dispatch calls that parse a single unit of text into a
// Node object which contains the whole statement. Dockerfiles have varied
// (but not usually unique, see ONBUILD for a unique example) parsing rules
// per-command, and these unify the processing in a way that makes it
// manageable.
import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
)
var (
errDockerfileJSONNesting = errors.New("You may not nest arrays in Dockerfile statements.")
)
// ignore the current argument. This will still leave a command parsed, but
// will not incorporate the arguments into the ast.
func parseIgnore(rest string) (*Node, map[string]bool, error) {
return &Node{}, nil, nil
}
// used for onbuild. Could potentially be used for anything that represents a
// statement with sub-statements.
//
// ONBUILD RUN foo bar -> (onbuild (run foo bar))
//
func parseSubCommand(rest string) (*Node, map[string]bool, error) {
_, child, err := parseLine(rest)
if err != nil {
return nil, nil, err
}
return &Node{Children: []*Node{child}}, nil, nil
}
// parse environment like statements. Note that this does *not* handle
// variable interpolation, which will be handled in the evaluator.
func parseEnv(rest string) (*Node, map[string]bool, error) {
node := &Node{}
rootnode := node
strs := TOKEN_WHITESPACE.Split(rest, 2)
if len(strs) < 2 {
return nil, nil, fmt.Errorf("ENV must have two arguments")
}
node.Value = strs[0]
node.Next = &Node{}
node.Next.Value = strs[1]
return rootnode, nil, nil
}
// parses a whitespace-delimited set of arguments. The result is effectively a
// linked list of string arguments.
func parseStringsWhitespaceDelimited(rest string) (*Node, map[string]bool, error) {
node := &Node{}
rootnode := node
prevnode := node
for _, str := range TOKEN_WHITESPACE.Split(rest, -1) { // use regexp
prevnode = node
node.Value = str
node.Next = &Node{}
node = node.Next
}
// XXX to get around regexp.Split *always* providing an empty string at the
// end due to how our loop is constructed, nil out the last node in the
// chain.
prevnode.Next = nil
return rootnode, nil, nil
}
// parsestring just wraps the string in quotes and returns a working node.
func parseString(rest string) (*Node, map[string]bool, error) {
n := &Node{}
n.Value = rest
return n, nil, nil
}
// parseJSON converts JSON arrays to an AST.
func parseJSON(rest string) (*Node, map[string]bool, error) {
var (
myJson []interface{}
next = &Node{}
orignext = next
prevnode = next
)
if err := json.Unmarshal([]byte(rest), &myJson); err != nil {
return nil, nil, err
}
for _, str := range myJson {
switch str.(type) {
case string:
case float64:
str = strconv.FormatFloat(str.(float64), 'G', -1, 64)
default:
return nil, nil, errDockerfileJSONNesting
}
next.Value = str.(string)
next.Next = &Node{}
prevnode = next
next = next.Next
}
prevnode.Next = nil
return orignext, map[string]bool{"json": true}, nil
}
// parseMaybeJSON determines if the argument appears to be a JSON array. If
// so, passes to parseJSON; if not, quotes the result and returns a single
// node.
func parseMaybeJSON(rest string) (*Node, map[string]bool, error) {
rest = strings.TrimSpace(rest)
node, attrs, err := parseJSON(rest)
if err == nil {
return node, attrs, nil
}
if err == errDockerfileJSONNesting {
return nil, nil, err
}
node = &Node{}
node.Value = rest
return node, nil, nil
}
// parseMaybeJSONToList determines if the argument appears to be a JSON array. If
// so, passes to parseJSON; if not, attmpts to parse it as a whitespace
// delimited string.
func parseMaybeJSONToList(rest string) (*Node, map[string]bool, error) {
rest = strings.TrimSpace(rest)
node, attrs, err := parseJSON(rest)
if err == nil {
return node, attrs, nil
}
if err == errDockerfileJSONNesting {
return nil, nil, err
}
return parseStringsWhitespaceDelimited(rest)
}

140
builder/parser/parser.go Normal file
View File

@@ -0,0 +1,140 @@
// This package implements a parser and parse tree dumper for Dockerfiles.
package parser
import (
"bufio"
"io"
"regexp"
"strings"
"unicode"
)
// Node is a structure used to represent a parse tree.
//
// In the node there are three fields, Value, Next, and Children. Value is the
// current token's string value. Next is always the next non-child token, and
// children contains all the children. Here's an example:
//
// (value next (child child-next child-next-next) next-next)
//
// This data structure is frankly pretty lousy for handling complex languages,
// but lucky for us the Dockerfile isn't very complicated. This structure
// works a little more effectively than a "proper" parse tree for our needs.
//
type Node struct {
Value string // actual content
Next *Node // the next item in the current sexp
Children []*Node // the children of this sexp
Attributes map[string]bool // special attributes for this node
Original string // original line used before parsing
}
var (
dispatch map[string]func(string) (*Node, map[string]bool, error)
TOKEN_WHITESPACE = regexp.MustCompile(`[\t\v\f\r ]+`)
TOKEN_LINE_CONTINUATION = regexp.MustCompile(`\\\s*$`)
TOKEN_COMMENT = regexp.MustCompile(`^#.*$`)
)
func init() {
// Dispatch Table. see line_parsers.go for the parse functions.
// The command is parsed and mapped to the line parser. The line parser
// recieves the arguments but not the command, and returns an AST after
// reformulating the arguments according to the rules in the parser
// functions. Errors are propogated up by Parse() and the resulting AST can
// be incorporated directly into the existing AST as a next.
dispatch = map[string]func(string) (*Node, map[string]bool, error){
"user": parseString,
"onbuild": parseSubCommand,
"workdir": parseString,
"env": parseEnv,
"maintainer": parseString,
"from": parseString,
"add": parseStringsWhitespaceDelimited,
"copy": parseStringsWhitespaceDelimited,
"run": parseMaybeJSON,
"cmd": parseMaybeJSON,
"entrypoint": parseMaybeJSON,
"expose": parseStringsWhitespaceDelimited,
"volume": parseMaybeJSONToList,
"insert": parseIgnore,
}
}
// parse a line and return the remainder.
func parseLine(line string) (string, *Node, error) {
if line = stripComments(line); line == "" {
return "", nil, nil
}
if TOKEN_LINE_CONTINUATION.MatchString(line) {
line = TOKEN_LINE_CONTINUATION.ReplaceAllString(line, "")
return line, nil, nil
}
cmd, args, err := splitCommand(line)
if err != nil {
return "", nil, err
}
node := &Node{}
node.Value = cmd
sexp, attrs, err := fullDispatch(cmd, args)
if err != nil {
return "", nil, err
}
if sexp.Value != "" || sexp.Next != nil || sexp.Children != nil {
node.Next = sexp
}
node.Attributes = attrs
node.Original = line
return "", node, nil
}
// The main parse routine. Handles an io.ReadWriteCloser and returns the root
// of the AST.
func Parse(rwc io.Reader) (*Node, error) {
root := &Node{}
scanner := bufio.NewScanner(rwc)
for scanner.Scan() {
scannedLine := strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace)
if stripComments(scannedLine) == "" {
continue
}
line, child, err := parseLine(scannedLine)
if err != nil {
return nil, err
}
if line != "" && child == nil {
for scanner.Scan() {
newline := scanner.Text()
if stripComments(strings.TrimSpace(newline)) == "" {
continue
}
line, child, err = parseLine(line + newline)
if err != nil {
return nil, err
}
if child != nil {
break
}
}
}
if child != nil {
root.Children = append(root.Children, child)
}
}
return root, nil
}

View File

@@ -0,0 +1,82 @@
package parser
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
const testDir = "testfiles"
const negativeTestDir = "testfiles-negative"
func getDirs(t *testing.T, dir string) []os.FileInfo {
f, err := os.Open(dir)
if err != nil {
t.Fatal(err)
}
defer f.Close()
dirs, err := f.Readdir(0)
if err != nil {
t.Fatal(err)
}
return dirs
}
func TestTestNegative(t *testing.T) {
for _, dir := range getDirs(t, negativeTestDir) {
dockerfile := filepath.Join(negativeTestDir, dir.Name(), "Dockerfile")
df, err := os.Open(dockerfile)
if err != nil {
t.Fatalf("Dockerfile missing for %s: %s", dir.Name(), err.Error())
}
_, err = Parse(df)
if err == nil {
t.Fatalf("No error parsing broken dockerfile for %s", dir.Name())
}
df.Close()
}
}
func TestTestData(t *testing.T) {
for _, dir := range getDirs(t, testDir) {
dockerfile := filepath.Join(testDir, dir.Name(), "Dockerfile")
resultfile := filepath.Join(testDir, dir.Name(), "result")
df, err := os.Open(dockerfile)
if err != nil {
t.Fatalf("Dockerfile missing for %s: %s", dir.Name(), err.Error())
}
rf, err := os.Open(resultfile)
if err != nil {
t.Fatalf("Result file missing for %s: %s", dir.Name(), err.Error())
}
ast, err := Parse(df)
if err != nil {
t.Fatalf("Error parsing %s's dockerfile: %s", dir.Name(), err.Error())
}
content, err := ioutil.ReadAll(rf)
if err != nil {
t.Fatalf("Error reading %s's result file: %s", dir.Name(), err.Error())
}
if ast.Dump()+"\n" != string(content) {
fmt.Fprintln(os.Stderr, "Result:\n"+ast.Dump())
fmt.Fprintln(os.Stderr, "Expected:\n"+string(content))
t.Fatalf("%s: AST dump of dockerfile does not match result", dir.Name())
}
df.Close()
rf.Close()
}
}

View File

@@ -0,0 +1,3 @@
FROM busybox
ENV PATH=PATH

View File

@@ -0,0 +1,2 @@
<html>
</html>

View File

@@ -0,0 +1 @@
CMD [ "echo", [ "nested json" ] ]

View File

@@ -0,0 +1,25 @@
FROM brimstone/ubuntu:14.04
MAINTAINER brimstone@the.narro.ws
# TORUN -v /var/run/docker.sock:/var/run/docker.sock
ENV GOPATH /go
# Set our command
ENTRYPOINT ["/usr/local/bin/consuldock"]
# Install the packages we need, clean up after them and us
RUN apt-get update \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean \
&& apt-get install -y --no-install-recommends git golang ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists \
&& go get -v github.com/brimstone/consuldock \
&& mv $GOPATH/bin/consuldock /usr/local/bin/consuldock \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \
&& apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \
&& rm /tmp/dpkg.* \
&& rm -rf $GOPATH

View File

@@ -0,0 +1,5 @@
(from "brimstone/ubuntu:14.04")
(maintainer "brimstone@the.narro.ws")
(env "GOPATH" "/go")
(entrypoint "/usr/local/bin/consuldock")
(run "apt-get update && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean && apt-get install -y --no-install-recommends git golang ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists && go get -v github.com/brimstone/consuldock && mv $GOPATH/bin/consuldock /usr/local/bin/consuldock && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty && apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') && rm /tmp/dpkg.* && rm -rf $GOPATH")

View File

@@ -0,0 +1,52 @@
FROM brimstone/ubuntu:14.04
CMD []
ENTRYPOINT ["/usr/bin/consul", "agent", "-server", "-data-dir=/consul", "-client=0.0.0.0", "-ui-dir=/webui"]
EXPOSE 8500 8600 8400 8301 8302
RUN apt-get update \
&& apt-get install -y unzip wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists
RUN cd /tmp \
&& wget https://dl.bintray.com/mitchellh/consul/0.3.1_web_ui.zip \
-O web_ui.zip \
&& unzip web_ui.zip \
&& mv dist /webui \
&& rm web_ui.zip
RUN apt-get update \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean \
&& apt-get install -y --no-install-recommends unzip wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists \
&& cd /tmp \
&& wget https://dl.bintray.com/mitchellh/consul/0.3.1_web_ui.zip \
-O web_ui.zip \
&& unzip web_ui.zip \
&& mv dist /webui \
&& rm web_ui.zip \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \
&& apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \
&& rm /tmp/dpkg.*
ENV GOPATH /go
RUN apt-get update \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean \
&& apt-get install -y --no-install-recommends git golang ca-certificates build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists \
&& go get -v github.com/hashicorp/consul \
&& mv $GOPATH/bin/consul /usr/bin/consul \
&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \
&& apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \
&& rm /tmp/dpkg.* \
&& rm -rf $GOPATH

View File

@@ -0,0 +1,9 @@
(from "brimstone/ubuntu:14.04")
(cmd)
(entrypoint "/usr/bin/consul" "agent" "-server" "-data-dir=/consul" "-client=0.0.0.0" "-ui-dir=/webui")
(expose "8500" "8600" "8400" "8301" "8302")
(run "apt-get update && apt-get install -y unzip wget && apt-get clean && rm -rf /var/lib/apt/lists")
(run "cd /tmp && wget https://dl.bintray.com/mitchellh/consul/0.3.1_web_ui.zip -O web_ui.zip && unzip web_ui.zip && mv dist /webui && rm web_ui.zip")
(run "apt-get update && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean && apt-get install -y --no-install-recommends unzip wget && apt-get clean && rm -rf /var/lib/apt/lists && cd /tmp && wget https://dl.bintray.com/mitchellh/consul/0.3.1_web_ui.zip -O web_ui.zip && unzip web_ui.zip && mv dist /webui && rm web_ui.zip && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty && apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') && rm /tmp/dpkg.*")
(env "GOPATH" "/go")
(run "apt-get update && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean && apt-get install -y --no-install-recommends git golang ca-certificates build-essential && apt-get clean && rm -rf /var/lib/apt/lists && go get -v github.com/hashicorp/consul && mv $GOPATH/bin/consul /usr/bin/consul && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty && apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') && rm /tmp/dpkg.* && rm -rf $GOPATH")

View File

@@ -0,0 +1,36 @@
FROM ubuntu:14.04
RUN echo hello\
world\
goodnight \
moon\
light\
ning
RUN echo hello \
world
RUN echo hello \
world
RUN echo hello \
goodbye\
frog
RUN echo hello \
world
RUN echo hi \
\
world \
\
good\
\
night
RUN echo goodbye\
frog
RUN echo good\
bye\
frog
RUN echo hello \
# this is a comment
# this is a comment with a blank line surrounding it
this is some more useful stuff

View File

@@ -0,0 +1,10 @@
(from "ubuntu:14.04")
(run "echo hello world goodnight moon lightning")
(run "echo hello world")
(run "echo hello world")
(run "echo hello goodbyefrog")
(run "echo hello world")
(run "echo hi world goodnight")
(run "echo goodbyefrog")
(run "echo goodbyefrog")
(run "echo hello this is some more useful stuff")

View File

@@ -0,0 +1,54 @@
FROM cpuguy83/ubuntu
ENV NAGIOS_HOME /opt/nagios
ENV NAGIOS_USER nagios
ENV NAGIOS_GROUP nagios
ENV NAGIOS_CMDUSER nagios
ENV NAGIOS_CMDGROUP nagios
ENV NAGIOSADMIN_USER nagiosadmin
ENV NAGIOSADMIN_PASS nagios
ENV APACHE_RUN_USER nagios
ENV APACHE_RUN_GROUP nagios
ENV NAGIOS_TIMEZONE UTC
RUN sed -i 's/universe/universe multiverse/' /etc/apt/sources.list
RUN apt-get update && apt-get install -y iputils-ping netcat build-essential snmp snmpd snmp-mibs-downloader php5-cli apache2 libapache2-mod-php5 runit bc postfix bsd-mailx
RUN ( egrep -i "^${NAGIOS_GROUP}" /etc/group || groupadd $NAGIOS_GROUP ) && ( egrep -i "^${NAGIOS_CMDGROUP}" /etc/group || groupadd $NAGIOS_CMDGROUP )
RUN ( id -u $NAGIOS_USER || useradd --system $NAGIOS_USER -g $NAGIOS_GROUP -d $NAGIOS_HOME ) && ( id -u $NAGIOS_CMDUSER || useradd --system -d $NAGIOS_HOME -g $NAGIOS_CMDGROUP $NAGIOS_CMDUSER )
ADD http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.1/nagios-3.5.1.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fcore%2Fthanks%2F%3Ft%3D1398863696&ts=1398863718&use_mirror=superb-dca3 /tmp/nagios.tar.gz
RUN cd /tmp && tar -zxvf nagios.tar.gz && cd nagios && ./configure --prefix=${NAGIOS_HOME} --exec-prefix=${NAGIOS_HOME} --enable-event-broker --with-nagios-command-user=${NAGIOS_CMDUSER} --with-command-group=${NAGIOS_CMDGROUP} --with-nagios-user=${NAGIOS_USER} --with-nagios-group=${NAGIOS_GROUP} && make all && make install && make install-config && make install-commandmode && cp sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf
ADD http://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz /tmp/
RUN cd /tmp && tar -zxvf nagios-plugins-1.5.tar.gz && cd nagios-plugins-1.5 && ./configure --prefix=${NAGIOS_HOME} && make && make install
RUN sed -i.bak 's/.*\=www\-data//g' /etc/apache2/envvars
RUN export DOC_ROOT="DocumentRoot $(echo $NAGIOS_HOME/share)"; sed -i "s,DocumentRoot.*,$DOC_ROOT," /etc/apache2/sites-enabled/000-default
RUN ln -s ${NAGIOS_HOME}/bin/nagios /usr/local/bin/nagios && mkdir -p /usr/share/snmp/mibs && chmod 0755 /usr/share/snmp/mibs && touch /usr/share/snmp/mibs/.foo
RUN echo "use_timezone=$NAGIOS_TIMEZONE" >> ${NAGIOS_HOME}/etc/nagios.cfg && echo "SetEnv TZ \"${NAGIOS_TIMEZONE}\"" >> /etc/apache2/conf.d/nagios.conf
RUN mkdir -p ${NAGIOS_HOME}/etc/conf.d && mkdir -p ${NAGIOS_HOME}/etc/monitor && ln -s /usr/share/snmp/mibs ${NAGIOS_HOME}/libexec/mibs
RUN echo "cfg_dir=${NAGIOS_HOME}/etc/conf.d" >> ${NAGIOS_HOME}/etc/nagios.cfg
RUN echo "cfg_dir=${NAGIOS_HOME}/etc/monitor" >> ${NAGIOS_HOME}/etc/nagios.cfg
RUN download-mibs && echo "mibs +ALL" > /etc/snmp/snmp.conf
RUN sed -i 's,/bin/mail,/usr/bin/mail,' /opt/nagios/etc/objects/commands.cfg && \
sed -i 's,/usr/usr,/usr,' /opt/nagios/etc/objects/commands.cfg
RUN cp /etc/services /var/spool/postfix/etc/
RUN mkdir -p /etc/sv/nagios && mkdir -p /etc/sv/apache && rm -rf /etc/sv/getty-5 && mkdir -p /etc/sv/postfix
ADD nagios.init /etc/sv/nagios/run
ADD apache.init /etc/sv/apache/run
ADD postfix.init /etc/sv/postfix/run
ADD postfix.stop /etc/sv/postfix/finish
ADD start.sh /usr/local/bin/start_nagios
ENV APACHE_LOCK_DIR /var/run
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
VOLUME ["/opt/nagios/var", "/opt/nagios/etc", "/opt/nagios/libexec", "/var/log/apache2", "/usr/share/snmp/mibs"]
CMD ["/usr/local/bin/start_nagios"]

View File

@@ -0,0 +1,40 @@
(from "cpuguy83/ubuntu")
(env "NAGIOS_HOME" "/opt/nagios")
(env "NAGIOS_USER" "nagios")
(env "NAGIOS_GROUP" "nagios")
(env "NAGIOS_CMDUSER" "nagios")
(env "NAGIOS_CMDGROUP" "nagios")
(env "NAGIOSADMIN_USER" "nagiosadmin")
(env "NAGIOSADMIN_PASS" "nagios")
(env "APACHE_RUN_USER" "nagios")
(env "APACHE_RUN_GROUP" "nagios")
(env "NAGIOS_TIMEZONE" "UTC")
(run "sed -i 's/universe/universe multiverse/' /etc/apt/sources.list")
(run "apt-get update && apt-get install -y iputils-ping netcat build-essential snmp snmpd snmp-mibs-downloader php5-cli apache2 libapache2-mod-php5 runit bc postfix bsd-mailx")
(run "( egrep -i \"^${NAGIOS_GROUP}\" /etc/group || groupadd $NAGIOS_GROUP ) && ( egrep -i \"^${NAGIOS_CMDGROUP}\" /etc/group || groupadd $NAGIOS_CMDGROUP )")
(run "( id -u $NAGIOS_USER || useradd --system $NAGIOS_USER -g $NAGIOS_GROUP -d $NAGIOS_HOME ) && ( id -u $NAGIOS_CMDUSER || useradd --system -d $NAGIOS_HOME -g $NAGIOS_CMDGROUP $NAGIOS_CMDUSER )")
(add "http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.1/nagios-3.5.1.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fcore%2Fthanks%2F%3Ft%3D1398863696&ts=1398863718&use_mirror=superb-dca3" "/tmp/nagios.tar.gz")
(run "cd /tmp && tar -zxvf nagios.tar.gz && cd nagios && ./configure --prefix=${NAGIOS_HOME} --exec-prefix=${NAGIOS_HOME} --enable-event-broker --with-nagios-command-user=${NAGIOS_CMDUSER} --with-command-group=${NAGIOS_CMDGROUP} --with-nagios-user=${NAGIOS_USER} --with-nagios-group=${NAGIOS_GROUP} && make all && make install && make install-config && make install-commandmode && cp sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf")
(add "http://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz" "/tmp/")
(run "cd /tmp && tar -zxvf nagios-plugins-1.5.tar.gz && cd nagios-plugins-1.5 && ./configure --prefix=${NAGIOS_HOME} && make && make install")
(run "sed -i.bak 's/.*\\=www\\-data//g' /etc/apache2/envvars")
(run "export DOC_ROOT=\"DocumentRoot $(echo $NAGIOS_HOME/share)\"; sed -i \"s,DocumentRoot.*,$DOC_ROOT,\" /etc/apache2/sites-enabled/000-default")
(run "ln -s ${NAGIOS_HOME}/bin/nagios /usr/local/bin/nagios && mkdir -p /usr/share/snmp/mibs && chmod 0755 /usr/share/snmp/mibs && touch /usr/share/snmp/mibs/.foo")
(run "echo \"use_timezone=$NAGIOS_TIMEZONE\" >> ${NAGIOS_HOME}/etc/nagios.cfg && echo \"SetEnv TZ \\\"${NAGIOS_TIMEZONE}\\\"\" >> /etc/apache2/conf.d/nagios.conf")
(run "mkdir -p ${NAGIOS_HOME}/etc/conf.d && mkdir -p ${NAGIOS_HOME}/etc/monitor && ln -s /usr/share/snmp/mibs ${NAGIOS_HOME}/libexec/mibs")
(run "echo \"cfg_dir=${NAGIOS_HOME}/etc/conf.d\" >> ${NAGIOS_HOME}/etc/nagios.cfg")
(run "echo \"cfg_dir=${NAGIOS_HOME}/etc/monitor\" >> ${NAGIOS_HOME}/etc/nagios.cfg")
(run "download-mibs && echo \"mibs +ALL\" > /etc/snmp/snmp.conf")
(run "sed -i 's,/bin/mail,/usr/bin/mail,' /opt/nagios/etc/objects/commands.cfg && sed -i 's,/usr/usr,/usr,' /opt/nagios/etc/objects/commands.cfg")
(run "cp /etc/services /var/spool/postfix/etc/")
(run "mkdir -p /etc/sv/nagios && mkdir -p /etc/sv/apache && rm -rf /etc/sv/getty-5 && mkdir -p /etc/sv/postfix")
(add "nagios.init" "/etc/sv/nagios/run")
(add "apache.init" "/etc/sv/apache/run")
(add "postfix.init" "/etc/sv/postfix/run")
(add "postfix.stop" "/etc/sv/postfix/finish")
(add "start.sh" "/usr/local/bin/start_nagios")
(env "APACHE_LOCK_DIR" "/var/run")
(env "APACHE_LOG_DIR" "/var/log/apache2")
(expose "80")
(volume "/opt/nagios/var" "/opt/nagios/etc" "/opt/nagios/libexec" "/var/log/apache2" "/usr/share/snmp/mibs")
(cmd "/usr/local/bin/start_nagios")

View File

@@ -0,0 +1,105 @@
# This file describes the standard way to build Docker, using docker
#
# Usage:
#
# # Assemble the full dev environment. This is slow the first time.
# docker build -t docker .
#
# # Mount your source in an interactive container for quick testing:
# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash
#
# # Run the test suite:
# docker run --privileged docker hack/make.sh test
#
# # Publish a release:
# docker run --privileged \
# -e AWS_S3_BUCKET=baz \
# -e AWS_ACCESS_KEY=foo \
# -e AWS_SECRET_KEY=bar \
# -e GPG_PASSPHRASE=gloubiboulga \
# docker hack/release.sh
#
# Note: Apparmor used to mess with privileged mode, but this is no longer
# the case. Therefore, you don't have to disable it anymore.
#
docker-version 0.6.1
FROM ubuntu:14.04
MAINTAINER Tianon Gravi <admwiggin@gmail.com> (@tianon)
# Packaged dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
apt-utils \
aufs-tools \
automake \
btrfs-tools \
build-essential \
curl \
dpkg-sig \
git \
iptables \
libapparmor-dev \
libcap-dev \
libsqlite3-dev \
lxc=1.0* \
mercurial \
pandoc \
parallel \
reprepro \
ruby1.9.1 \
ruby1.9.1-dev \
s3cmd=1.1.0* \
--no-install-recommends
# Get lvm2 source for compiling statically
RUN git clone --no-checkout https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 && cd /usr/local/lvm2 && git checkout -q v2_02_103
# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags
# note: we don't use "git clone -b" above because it then spews big nasty warnings about 'detached HEAD' state that we can't silence as easily as we can silence them using "git checkout" directly
# Compile and install lvm2
RUN cd /usr/local/lvm2 && ./configure --enable-static_link && make device-mapper && make install_device-mapper
# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
# Install Go
RUN curl -sSL https://golang.org/dl/go1.3.src.tar.gz | tar -v -C /usr/local -xz
ENV PATH /usr/local/go/bin:$PATH
ENV GOPATH /go:/go/src/github.com/docker/docker/vendor
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
# Compile Go for cross compilation
ENV DOCKER_CROSSPLATFORMS \
linux/386 linux/arm \
darwin/amd64 darwin/386 \
freebsd/amd64 freebsd/386 freebsd/arm
# (set an explicit GOARM of 5 for maximum compatibility)
ENV GOARM 5
RUN cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
# Grab Go's cover tool for dead-simple code coverage testing
RUN go get golang.org/x/tools/cmd/cover
# TODO replace FPM with some very minimal debhelper stuff
RUN gem install --no-rdoc --no-ri fpm --version 1.0.2
# Get the "busybox" image source so we can build locally instead of pulling
RUN git clone -b buildroot-2014.02 https://github.com/jpetazzo/docker-busybox.git /docker-busybox
# Setup s3cmd config
RUN /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY' > /.s3cfg
# Set user.email so crosbymichael's in-container merge commits go smoothly
RUN git config --global user.email 'docker-dummy@example.com'
# Add an unprivileged user to be used for tests which need it
RUN groupadd -r docker
RUN useradd --create-home --gid docker unprivilegeduser
VOLUME /var/lib/docker
WORKDIR /go/src/github.com/docker/docker
ENV DOCKER_BUILDTAGS apparmor selinux
# Wrap all commands in the "docker-in-docker" script to allow nested containers
ENTRYPOINT ["hack/dind"]
# Upload docker source
COPY . /go/src/github.com/docker/docker

View File

@@ -0,0 +1,25 @@
(docker-version)
(from "ubuntu:14.04")
(maintainer "Tianon Gravi <admwiggin@gmail.com> (@tianon)")
(run "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils aufs-tools automake btrfs-tools build-essential curl dpkg-sig git iptables libapparmor-dev libcap-dev libsqlite3-dev lxc=1.0* mercurial pandoc parallel reprepro ruby1.9.1 ruby1.9.1-dev s3cmd=1.1.0* --no-install-recommends")
(run "git clone --no-checkout https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 && cd /usr/local/lvm2 && git checkout -q v2_02_103")
(run "cd /usr/local/lvm2 && ./configure --enable-static_link && make device-mapper && make install_device-mapper")
(run "curl -sSL https://golang.org/dl/go1.3.src.tar.gz | tar -v -C /usr/local -xz")
(env "PATH" "/usr/local/go/bin:$PATH")
(env "GOPATH" "/go:/go/src/github.com/docker/docker/vendor")
(run "cd /usr/local/go/src && ./make.bash --no-clean 2>&1")
(env "DOCKER_CROSSPLATFORMS" "linux/386 linux/arm darwin/amd64 darwin/386 freebsd/amd64 freebsd/386 freebsd/arm")
(env "GOARM" "5")
(run "cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'")
(run "go get golang.org/x/tools/cmd/cover")
(run "gem install --no-rdoc --no-ri fpm --version 1.0.2")
(run "git clone -b buildroot-2014.02 https://github.com/jpetazzo/docker-busybox.git /docker-busybox")
(run "/bin/echo -e '[default]\\naccess_key=$AWS_ACCESS_KEY\\nsecret_key=$AWS_SECRET_KEY' > /.s3cfg")
(run "git config --global user.email 'docker-dummy@example.com'")
(run "groupadd -r docker")
(run "useradd --create-home --gid docker unprivilegeduser")
(volume "/var/lib/docker")
(workdir "/go/src/github.com/docker/docker")
(env "DOCKER_BUILDTAGS" "apparmor selinux")
(entrypoint "hack/dind")
(copy "." "/go/src/github.com/docker/docker")

View File

@@ -0,0 +1,14 @@
FROM ubuntu:14.04
MAINTAINER Erik \\Hollensbe <erik@hollensbe.org>\"
RUN apt-get \update && \
apt-get \"install znc -y
ADD \conf\\" /.znc
RUN foo \
bar \
baz
CMD [ "\/usr\\\"/bin/znc", "-f", "-r" ]

View File

@@ -0,0 +1,6 @@
(from "ubuntu:14.04")
(maintainer "Erik \\\\Hollensbe <erik@hollensbe.org>\\\"")
(run "apt-get \\update && apt-get \\\"install znc -y")
(add "\\conf\\\\\"" "/.znc")
(run "foo bar baz")
(cmd "/usr\\\"/bin/znc" "-f" "-r")

View File

@@ -0,0 +1,15 @@
FROM ubuntu:14.04
RUN apt-get update && apt-get install wget -y
RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
RUN dpkg -i influxdb_latest_amd64.deb
RUN rm -r /opt/influxdb/shared
VOLUME /opt/influxdb/shared
CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml
EXPOSE 8083
EXPOSE 8086
EXPOSE 8090
EXPOSE 8099

View File

@@ -0,0 +1,11 @@
(from "ubuntu:14.04")
(run "apt-get update && apt-get install wget -y")
(run "wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb")
(run "dpkg -i influxdb_latest_amd64.deb")
(run "rm -r /opt/influxdb/shared")
(volume "/opt/influxdb/shared")
(cmd "/usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml")
(expose "8083")
(expose "8086")
(expose "8090")
(expose "8099")

View File

@@ -0,0 +1 @@
CMD "[\"echo\", \"Phew, I just managed to escaped those double quotes\"]"

View File

@@ -0,0 +1 @@
(cmd "\"[\\\"echo\\\", \\\"Phew, I just managed to escaped those double quotes\\\"]\"")

View File

@@ -0,0 +1 @@
CMD '["echo", "Well, JSON in a string is JSON too?"]'

View File

@@ -0,0 +1 @@
(cmd "'[\"echo\", \"Well, JSON in a string is JSON too?\"]'")

View File

@@ -0,0 +1 @@
CMD ['echo','single quotes are invalid JSON']

View File

@@ -0,0 +1 @@
(cmd "['echo','single quotes are invalid JSON']")

View File

@@ -0,0 +1 @@
CMD ["echo", "Please, close the brackets when you're done"

View File

@@ -0,0 +1 @@
(cmd "[\"echo\", \"Please, close the brackets when you're done\"")

View File

@@ -0,0 +1 @@
CMD ["echo", "look ma, no quote!]

View File

@@ -0,0 +1 @@
(cmd "[\"echo\", \"look ma, no quote!]")

View File

@@ -0,0 +1,7 @@
FROM ubuntu:14.04
MAINTAINER James Turnbull "james@example.com"
ENV REFRESHED_AT 2014-06-01
RUN apt-get update
RUN apt-get -y install redis-server redis-tools
EXPOSE 6379
ENTRYPOINT [ "/usr/bin/redis-server" ]

View File

@@ -0,0 +1,7 @@
(from "ubuntu:14.04")
(maintainer "James Turnbull \"james@example.com\"")
(env "REFRESHED_AT" "2014-06-01")
(run "apt-get update")
(run "apt-get -y install redis-server redis-tools")
(expose "6379")
(entrypoint "/usr/bin/redis-server")

View File

@@ -0,0 +1,48 @@
FROM busybox:buildroot-2014.02
MAINTAINER docker <docker@docker.io>
ONBUILD RUN ["echo", "test"]
ONBUILD RUN echo test
ONBUILD COPY . /
# RUN Commands \
# linebreak in comment \
RUN ["ls", "-la"]
RUN ["echo", "'1234'"]
RUN echo "1234"
RUN echo 1234
RUN echo '1234' && \
echo "456" && \
echo 789
RUN sh -c 'echo root:testpass \
> /tmp/passwd'
RUN mkdir -p /test /test2 /test3/test
# ENV \
ENV SCUBA 1 DUBA 3
ENV SCUBA "1 DUBA 3"
# CMD \
CMD ["echo", "test"]
CMD echo test
CMD echo "test"
CMD echo 'test'
CMD echo 'test' | wc -
#EXPOSE\
EXPOSE 3000
EXPOSE 9000 5000 6000
USER docker
USER docker:root
VOLUME ["/test"]
VOLUME ["/test", "/test2"]
VOLUME /test3
WORKDIR /test
ADD . /
COPY . copy

View File

@@ -0,0 +1,29 @@
(from "busybox:buildroot-2014.02")
(maintainer "docker <docker@docker.io>")
(onbuild (run "echo" "test"))
(onbuild (run "echo test"))
(onbuild (copy "." "/"))
(run "ls" "-la")
(run "echo" "'1234'")
(run "echo \"1234\"")
(run "echo 1234")
(run "echo '1234' && echo \"456\" && echo 789")
(run "sh -c 'echo root:testpass > /tmp/passwd'")
(run "mkdir -p /test /test2 /test3/test")
(env "SCUBA" "1 DUBA 3")
(env "SCUBA" "\"1 DUBA 3\"")
(cmd "echo" "test")
(cmd "echo test")
(cmd "echo \"test\"")
(cmd "echo 'test'")
(cmd "echo 'test' | wc -")
(expose "3000")
(expose "9000" "5000" "6000")
(user "docker")
(user "docker:root")
(volume "/test")
(volume "/test" "/test2")
(volume "/test3")
(workdir "/test")
(add "." "/")
(copy "." "copy")

View File

@@ -0,0 +1,16 @@
FROM ubuntu:14.04
RUN apt-get update -qy && apt-get install mutt offlineimap vim-nox abook elinks curl tmux cron zsh -y
ADD .muttrc /
ADD .offlineimaprc /
ADD .tmux.conf /
ADD mutt /.mutt
ADD vim /.vim
ADD vimrc /.vimrc
ADD crontab /etc/crontab
RUN chmod 644 /etc/crontab
RUN mkdir /Mail
RUN mkdir /.offlineimap
RUN echo "export TERM=screen-256color" >/.zshenv
CMD setsid cron; tmux -2

View File

@@ -0,0 +1,14 @@
(from "ubuntu:14.04")
(run "apt-get update -qy && apt-get install mutt offlineimap vim-nox abook elinks curl tmux cron zsh -y")
(add ".muttrc" "/")
(add ".offlineimaprc" "/")
(add ".tmux.conf" "/")
(add "mutt" "/.mutt")
(add "vim" "/.vim")
(add "vimrc" "/.vimrc")
(add "crontab" "/etc/crontab")
(run "chmod 644 /etc/crontab")
(run "mkdir /Mail")
(run "mkdir /.offlineimap")
(run "echo \"export TERM=screen-256color\" >/.zshenv")
(cmd "setsid cron; tmux -2")

View File

@@ -0,0 +1,3 @@
FROM foo
VOLUME /opt/nagios/var /opt/nagios/etc /opt/nagios/libexec /var/log/apache2 /usr/share/snmp/mibs

View File

@@ -0,0 +1,2 @@
(from "foo")
(volume "/opt/nagios/var" "/opt/nagios/etc" "/opt/nagios/libexec" "/var/log/apache2" "/usr/share/snmp/mibs")

View File

@@ -0,0 +1,7 @@
FROM ubuntu:14.04
RUN apt-get update && apt-get install libcap2-bin mumble-server -y
ADD ./mumble-server.ini /etc/mumble-server.ini
CMD /usr/sbin/murmurd

View File

@@ -0,0 +1,4 @@
(from "ubuntu:14.04")
(run "apt-get update && apt-get install libcap2-bin mumble-server -y")
(add "./mumble-server.ini" "/etc/mumble-server.ini")
(cmd "/usr/sbin/murmurd")

View File

@@ -0,0 +1,14 @@
FROM ubuntu:14.04
MAINTAINER Erik Hollensbe <erik@hollensbe.org>
RUN apt-get update && apt-get install nginx-full -y
RUN rm -rf /etc/nginx
ADD etc /etc/nginx
RUN chown -R root:root /etc/nginx
RUN /usr/sbin/nginx -qt
RUN mkdir /www
CMD ["/usr/sbin/nginx"]
VOLUME /www
EXPOSE 80

View File

@@ -0,0 +1,11 @@
(from "ubuntu:14.04")
(maintainer "Erik Hollensbe <erik@hollensbe.org>")
(run "apt-get update && apt-get install nginx-full -y")
(run "rm -rf /etc/nginx")
(add "etc" "/etc/nginx")
(run "chown -R root:root /etc/nginx")
(run "/usr/sbin/nginx -qt")
(run "mkdir /www")
(cmd "/usr/sbin/nginx")
(volume "/www")
(expose "80")

View File

@@ -0,0 +1,23 @@
FROM ubuntu:12.04
EXPOSE 27015
EXPOSE 27005
EXPOSE 26901
EXPOSE 27020
RUN apt-get update && apt-get install libc6-dev-i386 curl unzip -y
RUN mkdir -p /steam
RUN curl http://media.steampowered.com/client/steamcmd_linux.tar.gz | tar vxz -C /steam
ADD ./script /steam/script
RUN /steam/steamcmd.sh +runscript /steam/script
RUN curl http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.0-linux.tar.gz | tar vxz -C /steam/tf2/tf
RUN curl http://mirror.pointysoftware.net/alliedmodders/sourcemod-1.5.3-linux.tar.gz | tar vxz -C /steam/tf2/tf
ADD ./server.cfg /steam/tf2/tf/cfg/server.cfg
ADD ./ctf_2fort.cfg /steam/tf2/tf/cfg/ctf_2fort.cfg
ADD ./sourcemod.cfg /steam/tf2/tf/cfg/sourcemod/sourcemod.cfg
RUN rm -r /steam/tf2/tf/addons/sourcemod/configs
ADD ./configs /steam/tf2/tf/addons/sourcemod/configs
RUN mkdir -p /steam/tf2/tf/addons/sourcemod/translations/en
RUN cp /steam/tf2/tf/addons/sourcemod/translations/*.txt /steam/tf2/tf/addons/sourcemod/translations/en
CMD cd /steam/tf2 && ./srcds_run -port 27015 +ip 0.0.0.0 +map ctf_2fort -autoupdate -steam_dir /steam -steamcmd_script /steam/script +tf_bot_quota 12 +tf_bot_quota_mode fill

View File

@@ -0,0 +1,20 @@
(from "ubuntu:12.04")
(expose "27015")
(expose "27005")
(expose "26901")
(expose "27020")
(run "apt-get update && apt-get install libc6-dev-i386 curl unzip -y")
(run "mkdir -p /steam")
(run "curl http://media.steampowered.com/client/steamcmd_linux.tar.gz | tar vxz -C /steam")
(add "./script" "/steam/script")
(run "/steam/steamcmd.sh +runscript /steam/script")
(run "curl http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.0-linux.tar.gz | tar vxz -C /steam/tf2/tf")
(run "curl http://mirror.pointysoftware.net/alliedmodders/sourcemod-1.5.3-linux.tar.gz | tar vxz -C /steam/tf2/tf")
(add "./server.cfg" "/steam/tf2/tf/cfg/server.cfg")
(add "./ctf_2fort.cfg" "/steam/tf2/tf/cfg/ctf_2fort.cfg")
(add "./sourcemod.cfg" "/steam/tf2/tf/cfg/sourcemod/sourcemod.cfg")
(run "rm -r /steam/tf2/tf/addons/sourcemod/configs")
(add "./configs" "/steam/tf2/tf/addons/sourcemod/configs")
(run "mkdir -p /steam/tf2/tf/addons/sourcemod/translations/en")
(run "cp /steam/tf2/tf/addons/sourcemod/translations/*.txt /steam/tf2/tf/addons/sourcemod/translations/en")
(cmd "cd /steam/tf2 && ./srcds_run -port 27015 +ip 0.0.0.0 +map ctf_2fort -autoupdate -steam_dir /steam -steamcmd_script /steam/script +tf_bot_quota 12 +tf_bot_quota_mode fill")

View File

@@ -0,0 +1,9 @@
FROM ubuntu:14.04
RUN apt-get update -qy && apt-get install tmux zsh weechat-curses -y
ADD .weechat /.weechat
ADD .tmux.conf /
RUN echo "export TERM=screen-256color" >/.zshenv
CMD zsh -c weechat

View File

@@ -0,0 +1,6 @@
(from "ubuntu:14.04")
(run "apt-get update -qy && apt-get install tmux zsh weechat-curses -y")
(add ".weechat" "/.weechat")
(add ".tmux.conf" "/")
(run "echo \"export TERM=screen-256color\" >/.zshenv")
(cmd "zsh -c weechat")

View File

@@ -0,0 +1,7 @@
FROM ubuntu:14.04
MAINTAINER Erik Hollensbe <erik@hollensbe.org>
RUN apt-get update && apt-get install znc -y
ADD conf /.znc
CMD [ "/usr/bin/znc", "-f", "-r" ]

View File

@@ -0,0 +1,5 @@
(from "ubuntu:14.04")
(maintainer "Erik Hollensbe <erik@hollensbe.org>")
(run "apt-get update && apt-get install znc -y")
(add "conf" "/.znc")
(cmd "/usr/bin/znc" "-f" "-r")

94
builder/parser/utils.go Normal file
View File

@@ -0,0 +1,94 @@
package parser
import (
"fmt"
"strings"
)
// QuoteString walks characters (after trimming), escapes any quotes and
// escapes, then wraps the whole thing in quotes. Very useful for generating
// argument output in nodes.
func QuoteString(str string) string {
result := ""
chars := strings.Split(strings.TrimSpace(str), "")
for _, char := range chars {
switch char {
case `"`:
result += `\"`
case `\`:
result += `\\`
default:
result += char
}
}
return `"` + result + `"`
}
// dumps the AST defined by `node` as a list of sexps. Returns a string
// suitable for printing.
func (node *Node) Dump() string {
str := ""
str += node.Value
for _, n := range node.Children {
str += "(" + n.Dump() + ")\n"
}
if node.Next != nil {
for n := node.Next; n != nil; n = n.Next {
if len(n.Children) > 0 {
str += " " + n.Dump()
} else {
str += " " + QuoteString(n.Value)
}
}
}
return strings.TrimSpace(str)
}
// performs the dispatch based on the two primal strings, cmd and args. Please
// look at the dispatch table in parser.go to see how these dispatchers work.
func fullDispatch(cmd, args string) (*Node, map[string]bool, error) {
fn := dispatch[cmd]
// Ignore invalid Dockerfile instructions
if fn == nil {
fn = parseIgnore
}
sexp, attrs, err := fn(args)
if err != nil {
return nil, nil, err
}
return sexp, attrs, nil
}
// splitCommand takes a single line of text and parses out the cmd and args,
// which are used for dispatching to more exact parsing functions.
func splitCommand(line string) (string, string, error) {
cmdline := TOKEN_WHITESPACE.Split(line, 2)
if len(cmdline) != 2 {
return "", "", fmt.Errorf("We do not understand this file. Please ensure it is a valid Dockerfile. Parser error at %q", line)
}
cmd := strings.ToLower(cmdline[0])
// the cmd should never have whitespace, but it's possible for the args to
// have trailing whitespace.
return cmd, strings.TrimSpace(cmdline[1]), nil
}
// covers comments and empty lines. Lines should be trimmed before passing to
// this function.
func stripComments(line string) string {
// string is already trimmed at this point
if TOKEN_COMMENT.MatchString(line) {
return TOKEN_COMMENT.ReplaceAllString(line, "")
}
return line
}

59
builder/support.go Normal file
View File

@@ -0,0 +1,59 @@
package builder
import (
"regexp"
"strings"
)
var (
// `\\\\+|[^\\]|\b|\A` - match any number of "\\" (ie, properly-escaped backslashes), or a single non-backslash character, or a word boundary, or beginning-of-line
// `\$` - match literal $
// `[[:alnum:]_]+` - match things like `$SOME_VAR`
// `{[[:alnum:]_]+}` - match things like `${SOME_VAR}`
tokenEnvInterpolation = regexp.MustCompile(`(\\|\\\\+|[^\\]|\b|\A)\$([[:alnum:]_]+|{[[:alnum:]_]+})`)
// this intentionally punts on more exotic interpolations like ${SOME_VAR%suffix} and lets the shell handle those directly
)
// handle environment replacement. Used in dispatcher.
func (b *Builder) replaceEnv(str string) string {
for _, match := range tokenEnvInterpolation.FindAllString(str, -1) {
idx := strings.Index(match, "\\$")
if idx != -1 {
if idx+2 >= len(match) {
str = strings.Replace(str, match, "\\$", -1)
continue
}
prefix := match[:idx]
stripped := match[idx+2:]
str = strings.Replace(str, match, prefix+"$"+stripped, -1)
continue
}
match = match[strings.Index(match, "$"):]
matchKey := strings.Trim(match, "${}")
for _, keyval := range b.Config.Env {
tmp := strings.SplitN(keyval, "=", 2)
if tmp[0] == matchKey {
str = strings.Replace(str, match, tmp[1], -1)
break
}
}
}
return str
}
func handleJsonArgs(args []string, attributes map[string]bool) []string {
if len(args) == 0 {
return []string{}
}
if attributes != nil && attributes["json"] {
return args
}
// literal string command, not an exec array
return []string{strings.Join(args, " ")}
}

View File

@@ -10,7 +10,6 @@ import (
"github.com/docker/docker/engine"
"github.com/docker/docker/events"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/registry"
)
func Register(eng *engine.Engine) error {
@@ -26,7 +25,8 @@ func Register(eng *engine.Engine) error {
if err := eng.Register("version", dockerVersion); err != nil {
return err
}
return registry.NewService().Install(eng)
return nil
}
// remote: a RESTful api for cross-docker communication
@@ -61,7 +61,7 @@ func dockerVersion(job *engine.Job) engine.Status {
v := &engine.Env{}
v.SetJson("Version", dockerversion.VERSION)
v.SetJson("ApiVersion", api.APIVERSION)
v.Set("GitCommit", dockerversion.GITCOMMIT)
v.SetJson("GitCommit", dockerversion.GITCOMMIT)
v.Set("GoVersion", runtime.Version())
v.Set("Os", runtime.GOOS)
v.Set("Arch", runtime.GOARCH)

View File

@@ -146,13 +146,14 @@ echo 'Optional Features:'
flags=(
MEMCG_SWAP
RESOURCE_COUNTERS
CGROUP_PERF
)
check_flags "${flags[@]}"
echo '- Storage Drivers:'
{
echo '- "'$(wrap_color 'aufs' blue)'":'
check_flags AUFS_FS | sed 's/^/ /'
check_flags AUFS_FS EXT4_FS_POSIX_ACL EXT4_FS_SECURITY | sed 's/^/ /'
if ! is_set AUFS_FS && grep -q aufs /proc/filesystems; then
echo " $(wrap_color '(note that some kernels include AUFS patches but not the AUFS_FS flag)' bold black)"
fi
@@ -161,7 +162,7 @@ echo '- Storage Drivers:'
check_flags BTRFS_FS | sed 's/^/ /'
echo '- "'$(wrap_color 'devicemapper' blue)'":'
check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS | sed 's/^/ /'
check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS EXT4_FS_POSIX_ACL EXT4_FS_SECURITY | sed 's/^/ /'
} | sed 's/^/ /'
echo

View File

@@ -25,63 +25,59 @@ __docker_q() {
docker 2>/dev/null "$@"
}
__docker_containers_all()
{
local containers="$( __docker_q ps -a -q )"
local names="$( __docker_q inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
__docker_containers_all() {
local IFS=$'\n'
local containers=( $(__docker_q ps -aq --no-trunc) )
if [ "$1" ]; then
containers=( $(__docker_q inspect --format "{{if $1}}{{.Id}}{{end}}" "${containers[@]}") )
fi
local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") )
names=( "${names[@]#/}" ) # trim off the leading "/" from the container names
unset IFS
COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") )
}
__docker_containers_running()
{
local containers="$( __docker_q ps -q )"
local names="$( __docker_q inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
__docker_containers_running() {
__docker_containers_all '.State.Running'
}
__docker_containers_stopped()
{
local containers="$( { __docker_q ps -a -q; __docker_q ps -q; } | sort | uniq -u )"
local names="$( __docker_q inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
__docker_containers_stopped() {
__docker_containers_all 'not .State.Running'
}
__docker_image_repos()
{
local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )"
COMPREPLY=( $( compgen -W "$repos" -- "$cur" ) )
__docker_containers_pauseable() {
__docker_containers_all 'and .State.Running (not .State.Paused)'
}
__docker_image_repos_and_tags()
{
local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )"
local images="$( __docker_q images | awk 'NR>1{print $1":"$2}' | grep -v '^<none>:' )"
COMPREPLY=( $( compgen -W "$repos $images" -- "$cur" ) )
__docker_containers_unpauseable() {
__docker_containers_all '.State.Paused'
}
__docker_image_repos() {
local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')"
COMPREPLY=( $(compgen -W "$repos" -- "$cur") )
}
__docker_image_repos_and_tags() {
local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')"
COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") )
__ltrim_colon_completions "$cur"
}
__docker_image_repos_and_tags_and_ids()
{
local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )"
local images="$( __docker_q images | awk 'NR>1{print $1":"$2}' | grep -v '^<none>:' )"
local ids="$( __docker_q images -a -q )"
COMPREPLY=( $( compgen -W "$repos $images $ids" -- "$cur" ) )
__docker_image_repos_and_tags_and_ids() {
local images="$(__docker_q images -a --no-trunc | awk 'NR>1 { print $3; if ($1 != "<none>") { print $1; print $1":"$2 } }')"
COMPREPLY=( $(compgen -W "$images" -- "$cur") )
__ltrim_colon_completions "$cur"
}
__docker_containers_and_images()
{
local containers="$( __docker_q ps -a -q )"
local names="$( __docker_q inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )"
local images="$( __docker_q images | awk 'NR>1{print $1":"$2}' | grep -v '^<none>:' )"
local ids="$( __docker_q images -a -q )"
COMPREPLY=( $( compgen -W "$containers $names $repos $images $ids" -- "$cur" ) )
__ltrim_colon_completions "$cur"
__docker_containers_and_images() {
__docker_containers_all
local containers=( "${COMPREPLY[@]}" )
__docker_image_repos_and_tags_and_ids
COMPREPLY+=( "${containers[@]}" )
}
__docker_pos_first_nonflag()
{
__docker_pos_first_nonflag() {
local argument_flags=$1
local counter=$cpos
@@ -103,8 +99,7 @@ __docker_pos_first_nonflag()
echo $counter
}
_docker_docker()
{
_docker_docker() {
case "$prev" in
-H)
return
@@ -118,13 +113,12 @@ _docker_docker()
COMPREPLY=( $( compgen -W "-H" -- "$cur" ) )
;;
*)
COMPREPLY=( $( compgen -W "$commands help" -- "$cur" ) )
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
;;
esac
}
_docker_attach()
{
_docker_attach() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--no-stdin --sig-proxy" -- "$cur" ) )
@@ -138,8 +132,7 @@ _docker_attach()
esac
}
_docker_build()
{
_docker_build() {
case "$prev" in
-t|--tag)
__docker_image_repos_and_tags
@@ -151,7 +144,7 @@ _docker_build()
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-t --tag -q --quiet --no-cache --rm" -- "$cur" ) )
COMPREPLY=( $( compgen -W "-t --tag -q --quiet --no-cache --rm --force-rm" -- "$cur" ) )
;;
*)
local counter="$(__docker_pos_first_nonflag '-t|--tag')"
@@ -162,8 +155,7 @@ _docker_build()
esac
}
_docker_commit()
{
_docker_commit() {
case "$prev" in
-m|--message|-a|--author|--run)
return
@@ -193,8 +185,7 @@ _docker_commit()
esac
}
_docker_cp()
{
_docker_cp() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
case "$cur" in
@@ -217,273 +208,7 @@ _docker_cp()
fi
}
_docker_diff()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_events()
{
case "$prev" in
--since)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--since" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_export()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_help()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
fi
}
_docker_history()
{
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet --no-trunc" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags_and_ids
fi
;;
esac
}
_docker_images()
{
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet -a --all --no-trunc -v --viz -t --tree" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos
fi
;;
esac
}
_docker_import()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
return
fi
(( counter++ ))
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
return
fi
}
_docker_info()
{
return
}
_docker_inspect()
{
case "$prev" in
-f|--format)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --format" -- "$cur" ) )
;;
*)
__docker_containers_and_images
;;
esac
}
_docker_kill()
{
__docker_containers_running
}
_docker_load()
{
return
}
_docker_login()
{
case "$prev" in
-u|--username|-p|--password|-e|--email)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-u --username -p --password -e --email" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_logs()
{
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --follow" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
;;
esac
}
_docker_port()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_ps()
{
case "$prev" in
--since|--before)
__docker_containers_all
;;
-n)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet -s --size -a --all --no-trunc -l --latest --since --before -n" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_pull()
{
case "$prev" in
-t|--tag)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-t --tag" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '-t|--tag')
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
fi
;;
esac
}
_docker_push()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
fi
}
_docker_restart()
{
case "$prev" in
-t|--time)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-t --time" -- "$cur" ) )
;;
*)
__docker_containers_all
;;
esac
}
_docker_rm()
{
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --force -l --link -v --volumes" -- "$cur" ) )
return
;;
*)
local force=
for arg in "${COMP_WORDS[@]}"; do
case "$arg" in
-f|--force)
__docker_containers_all
return
;;
esac
done
__docker_containers_stopped
return
;;
esac
}
_docker_rmi()
{
__docker_image_repos_and_tags_and_ids
}
_docker_run()
{
_docker_create() {
case "$prev" in
-a|--attach)
COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) )
@@ -539,7 +264,7 @@ _docker_run()
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--rm -d --detach -n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env -p --publish --expose --dns --volumes-from --lxc-conf" -- "$cur" ) )
COMPREPLY=( $( compgen -W "-n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir -c --cpu-shares --name -a --attach -v --volume --link -e --env -p --publish --expose --dns --volumes-from --lxc-conf" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf')
@@ -551,16 +276,346 @@ _docker_run()
esac
}
_docker_save()
{
_docker_diff() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_events() {
case "$prev" in
--since)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--since" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_exec() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-d --detach -i --interactive -t --tty" -- "$cur" ) )
;;
*)
__docker_containers_running
;;
esac
}
_docker_export() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_help() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
fi
}
_docker_history() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet --no-trunc" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags_and_ids
fi
;;
esac
}
_docker_images() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet -a --all --no-trunc -v --viz -t --tree" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos
fi
;;
esac
}
_docker_import() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
return
fi
(( counter++ ))
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
return
fi
}
_docker_info() {
return
}
_docker_inspect() {
case "$prev" in
-f|--format)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --format" -- "$cur" ) )
;;
*)
__docker_containers_and_images
;;
esac
}
_docker_kill() {
__docker_containers_running
}
_docker_load() {
return
}
_docker_login() {
case "$prev" in
-u|--username|-p|--password|-e|--email)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-u --username -p --password -e --email" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_logs() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --follow" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
;;
esac
}
_docker_pause() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_pauseable
fi
}
_docker_port() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_all
fi
}
_docker_ps() {
case "$prev" in
--since|--before)
__docker_containers_all
;;
-n)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-q --quiet -s --size -a --all --no-trunc -l --latest --since --before -n" -- "$cur" ) )
;;
*)
;;
esac
}
_docker_pull() {
case "$prev" in
-t|--tag)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-t --tag" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '-t|--tag')
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
fi
;;
esac
}
_docker_push() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags
fi
}
_docker_restart() {
case "$prev" in
-t|--time)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-t --time" -- "$cur" ) )
;;
*)
__docker_containers_all
;;
esac
}
_docker_rm() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --force -l --link -v --volumes" -- "$cur" ) )
return
;;
*)
local force=
for arg in "${COMP_WORDS[@]}"; do
case "$arg" in
-f|--force)
__docker_containers_all
return
;;
esac
done
__docker_containers_stopped
return
;;
esac
}
_docker_rmi() {
__docker_image_repos_and_tags_and_ids
}
_docker_run() {
case "$prev" in
-a|--attach)
COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) )
return
;;
--cidfile|--env-file)
_filedir
return
;;
--volumes-from)
__docker_containers_all
return
;;
-v|--volume)
case "$cur" in
*:*)
# TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine)
;;
'')
COMPREPLY=( $( compgen -W '/' -- "$cur" ) )
compopt -o nospace
;;
/*)
_filedir
compopt -o nospace
;;
esac
return
;;
-e|--env)
COMPREPLY=( $( compgen -e -- "$cur" ) )
compopt -o nospace
return
;;
--link)
case "$cur" in
*:*)
;;
*)
__docker_containers_running
COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
compopt -o nospace
;;
esac
return
;;
--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-p|--publish|--expose|--dns|--lxc-conf)
return
;;
*)
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--rm -d --detach -n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env -p --publish --expose --dns --volumes-from --lxc-conf --security-opt" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf|--security-opt')
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags_and_ids
fi
;;
esac
}
_docker_save() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_image_repos_and_tags_and_ids
fi
}
_docker_search()
{
_docker_search() {
case "$prev" in
-s|--stars)
return
@@ -578,8 +633,7 @@ _docker_search()
esac
}
_docker_start()
{
_docker_start() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-a --attach -i --interactive" -- "$cur" ) )
@@ -590,8 +644,7 @@ _docker_start()
esac
}
_docker_stop()
{
_docker_stop() {
case "$prev" in
-t|--time)
return
@@ -610,8 +663,7 @@ _docker_stop()
esac
}
_docker_tag()
{
_docker_tag() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-f --force" -- "$cur" ) )
@@ -633,61 +685,68 @@ _docker_tag()
esac
}
_docker_top()
{
_docker_unpause() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_unpauseable
fi
}
_docker_top() {
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_running
fi
}
_docker_version()
{
_docker_version() {
return
}
_docker_wait()
{
_docker_wait() {
__docker_containers_all
}
_docker()
{
local commands="
attach
build
commit
cp
diff
events
export
history
images
import
info
insert
inspect
kill
load
login
logs
port
ps
pull
push
restart
rm
rmi
run
save
search
start
stop
tag
top
version
wait
"
_docker() {
local commands=(
attach
build
commit
cp
create
diff
events
exec
export
history
images
import
info
insert
inspect
kill
load
login
logs
pause
port
ps
pull
push
restart
rm
rmi
run
save
search
start
stop
tag
top
unpause
version
wait
)
COMPREPLY=()
local cur prev words cword

View File

@@ -16,7 +16,7 @@
function __fish_docker_no_subcommand --description 'Test if docker has yet to be given the subcommand'
for i in (commandline -opc)
if contains -- $i attach build commit cp diff events export history images import info insert inspect kill load login logs port ps pull push restart rm rmi run save search start stop tag top version wait
if contains -- $i attach build commit cp create diff events export history images import info insert inspect kill load login logs port ps pull push restart rm rmi run save search start stop tag top version wait
return 1
end
end
@@ -72,6 +72,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from attach' -a '(__fish_pri
# build
complete -c docker -f -n '__fish_docker_no_subcommand' -a build -d 'Build an image from a Dockerfile'
complete -c docker -A -f -n '__fish_seen_subcommand_from build' -l force-rm -d 'Always remove intermediate containers, even after unsuccessful builds'
complete -c docker -A -f -n '__fish_seen_subcommand_from build' -l no-cache -d 'Do not use cache when building the image'
complete -c docker -A -f -n '__fish_seen_subcommand_from build' -s q -l quiet -d 'Suppress the verbose output generated by the containers'
complete -c docker -A -f -n '__fish_seen_subcommand_from build' -l rm -d 'Remove intermediate containers after a successful build'
@@ -87,6 +88,33 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from commit' -a '(__fish_pri
# cp
complete -c docker -f -n '__fish_docker_no_subcommand' -a cp -d "Copy files/folders from a container's filesystem to the host path"
# create
complete -c docker -f -n '__fish_docker_no_subcommand' -a run -d 'Run a command in a new container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s P -l publish-all -d 'Publish all exposed ports to the host interfaces'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s a -l attach -d 'Attach to stdin, stdout or stderr.'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s c -l cpu-shares -d 'CPU shares (relative weight)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l cidfile -d 'Write the container ID to the file'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l dns -d 'Set custom dns servers'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s e -l env -d 'Set environment variables'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l entrypoint -d 'Overwrite the default entrypoint of the image'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l expose -d 'Expose a port from the container without publishing it to your host'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s h -l hostname -d 'Container host name'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s i -l interactive -d 'Keep stdin open even if not attached'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l link -d 'Add link to another container (name:alias)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l lxc-conf -d 'Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s m -l memory -d 'Memory limit (format: <number><optional unit>, where unit = b, k, m or g)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s n -l networking -d 'Enable networking for this container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l name -d 'Assign a name to the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s p -l publish -d "Publish a container's port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use 'docker port' to see the actual mapping)"
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l privileged -d 'Give extended privileges to this container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s t -l tty -d 'Allocate a pseudo-tty'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s u -l user -d 'Username or UID'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s v -l volume -d 'Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l volumes-from -d 'Mount volumes from the specified container(s)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s w -l workdir -d 'Working directory inside the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -a '(__fish_print_docker_images)' -d "Image"
# diff
complete -c docker -f -n '__fish_docker_no_subcommand' -a diff -d "Inspect changes on a container's filesystem"
complete -c docker -A -f -n '__fish_seen_subcommand_from diff' -a '(__fish_print_docker_containers all)' -d "Container"

View File

@@ -5,7 +5,7 @@
# version: 0.3.0
# github: https://github.com/felixr/docker-zsh-completion
#
# contributers:
# contributors:
# - Felix Riedel
# - Vincent Bernat
#
@@ -37,65 +37,86 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
__parse_docker_list() {
awk '
NR == 1 {
idx=1;i=0;f[i]=0
header=$0
while ( match(header, / ([A-Z]+|[A-Z]+ [A-Z]+)/) ) {
idx += RSTART+1
f[++i]=idx
header = substr($0,idx)
}
f[++i]=999
}
__docker_get_containers() {
local kind expl
declare -a running stopped lines args
NR > 1 '"$1"' {
for(j=0;j<i;j++) {
x[j] = substr($0, f[j], f[j+1]-f[j]-1)
gsub(/[ ]+$/, "", x[j])
kind=$1
shift
[[ $kind = (stopped|all) ]] && args=($args -a)
lines=(${(f)"$(_call_program commands docker ps ${args})"})
# Parse header line to find columns
local i=1 j=1 k header=${lines[1]}
declare -A begin end
while (( $j < ${#header} - 1 )) {
i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1))
j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1))
k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2))
begin[${header[$i,$(($j-1))]}]=$i
end[${header[$i,$(($j-1))]}]=$k
}
printf("%s:%7s, %s\n", x[0], x[3], x[1])
if (x[6] != "") {
split(x[6], names, /,/)
for (name in names) printf("%s:%7s, %s\n", names[name], x[3], x[1])
}
}
'| sed -e 's/ \([hdwm]\)\(inutes\|ays\|ours\|eeks\)/\1/'
lines=(${lines[2,-1]})
# Container ID
local line
local s
for line in $lines; do
s="${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}"
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
stopped=($stopped $s)
else
running=($running $s)
fi
done
# Names
local name
local -a names
for line in $lines; do
names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
for name in $names; do
s="${name}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}"
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
stopped=($stopped $s)
else
running=($running $s)
fi
done
done
[[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running
[[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped
}
__docker_stoppedcontainers() {
local expl
declare -a stoppedcontainers
stoppedcontainers=(${(f)"$(_call_program commands docker ps -a | __parse_docker_list '&& / Exit/')"})
_describe -t containers-stopped "Stopped Containers" stoppedcontainers "$@"
__docker_get_containers stopped "$@"
}
__docker_runningcontainers() {
local expl
declare -a containers
containers=(${(f)"$(_call_program commands docker ps | __parse_docker_list)"})
_describe -t containers-active "Running Containers" containers "$@"
__docker_get_containers running "$@"
}
__docker_containers () {
__docker_stoppedcontainers "$@"
__docker_runningcontainers "$@"
__docker_get_containers all "$@"
}
__docker_images () {
local expl
declare -a images
images=(${(f)"$(_call_program commands docker images | awk '(NR > 1 && $1 != "<none>"){printf("%s", $1);if ($2 != "<none>") printf("\\:%s", $2); printf("\n")}')"})
images=($images ${(f)"$(_call_program commands docker images | awk '(NR > 1){printf("%s:%-15s in %s\n", $3,$2,$1)}')"})
_describe -t docker-images "Images" images
images=(${${${${(f)"$(_call_program commands docker images)"}[2,-1]}/ ##/\\:}%% *})
images=(${${images%\\:<none>}#<none>} ${${${(f)"$(_call_program commands docker images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}})
_describe -t docker-images "images" images
}
__docker_tags() {
local expl
declare -a tags
tags=(${(f)"$(_call_program commands docker images | awk '(NR>1){print $2}'| sort | uniq)"})
tags=(${${${${${(f)"$(_call_program commands docker images)"}#* }## #}%% *}[2,-1]})
_describe -t docker-tags "tags" tags
}
@@ -124,16 +145,15 @@ __docker_search() {
if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
&& ! _retrieve_cache ${cachename#_}; then
_message "Searching for ${searchterm}..."
result=(${(f)"$(_call_program commands docker search ${searchterm} | awk '(NR>2){print $1}')"})
result=(${${${(f)"$(_call_program commands docker search ${searchterm})"}%% *}[2,-1]})
_store_cache ${cachename#_} result
fi
_wanted dockersearch expl 'Available images' compadd -a result
_wanted dockersearch expl 'available images' compadd -a result
}
__docker_caching_policy()
{
# oldp=( "$1"(Nmh+24) ) # 24 hour
oldp=( "$1"(Nmh+1) ) # 24 hour
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
@@ -141,8 +161,8 @@ __docker_caching_policy()
__docker_repositories () {
local expl
declare -a repos
repos=(${(f)"$(_call_program commands docker images | sed -e '1d' -e 's/[ ].*//' | sort | uniq)"})
_describe -t docker-repos "Repositories" repos "$@"
repos=(${${${(f)"$(_call_program commands docker images)"}%% *}[2,-1]})
_describe -t docker-repos "repositories" repos "$@"
}
__docker_commands () {
@@ -157,8 +177,7 @@ __docker_commands () {
if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
&& ! _retrieve_cache docker_subcommands;
then
_docker_subcommands=(${${(f)"$(_call_program commands
docker 2>&1 | sed -e '1,6d' -e '/^[ ]*$/d' -e 's/[ ]*\([^ ]\+\)\s*\([^ ].*\)/\1:\2/' )"}})
_docker_subcommands=(${${${${(f)"$(_call_program commands docker 2>&1)"}[5,-1]}## #}/ ##/:})
_docker_subcommands=($_docker_subcommands 'help:Show help for a command')
_store_cache docker_subcommands _docker_subcommands
fi
@@ -176,16 +195,17 @@ __docker_subcommand () {
;;
(build)
_arguments \
'--force-rm[Always remove intermediate containers, even after unsuccessful builds]' \
'--no-cache[Do not use cache when building the image]' \
'-q[Suppress verbose build output]' \
'--rm[Remove intermediate containers after a successful build]' \
'-t=-:repository:__docker_repositories_with_tags' \
'-t:repository:__docker_repositories_with_tags' \
':path or URL:_directories'
;;
(commit)
_arguments \
'--author=-[Author]:author: ' \
'-m=-[Commit message]:message: ' \
'-m[Commit message]:message: ' \
'--run=-[Configuration automatically applied when the image is run]:configuration: ' \
':container:__docker_containers' \
':repository:__docker_repositories_with_tags'
@@ -204,9 +224,42 @@ __docker_subcommand () {
;;
esac
;;
(create)
_arguments \
'-P[Publish all exposed ports to the host]' \
'-a[Attach to stdin, stdout or stderr]' \
'-c=-[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
'--cidfile=-[Write the container ID to the file]:CID file:_files' \
'*--dns=-[Set custom dns servers]:dns server: ' \
'*-e=-[Set environment variables]:environment variable: ' \
'--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \
'*--expose=-[Expose a port from the container without publishing it]: ' \
'-h=-[Container host name]:hostname:_hosts' \
'-i[Keep stdin open even if not attached]' \
'--link=-[Add link to another container]:link:->link' \
'--lxc-conf=-[Add custom lxc options]:lxc options: ' \
'-m=-[Memory limit (in bytes)]:limit: ' \
'--name=-[Container name]:name: ' \
'*-p=-[Expose a container'"'"'s port to the host]:port:_ports' \
'--privileged[Give extended privileges to this container]' \
'-t[Allocate a pseudo-tty]' \
'-u=-[Username or UID]:user:_users' \
'*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
'--volumes-from=-[Mount volumes from the specified container]:volume: ' \
'-w=-[Working directory inside the container]:directory:_directories' \
'(-):images:__docker_images' \
'(-):command: _command_names -e' \
'*::arguments: _normal'
(diff|export)
_arguments '*:containers:__docker_containers'
;;
(exec)
_arguments \
'-d[Detached mode: leave the container running in the background]' \
'-i[Keep stdin open even if not attached]' \
'-t[Allocate a pseudo-tty]' \
':containers:__docker_runningcontainers'
;;
(history)
_arguments \
'--no-trunc[Do not truncate output]' \
@@ -251,9 +304,9 @@ __docker_subcommand () {
;;
(login)
_arguments \
'-e=-[Email]:email: ' \
'-p=-[Password]:password: ' \
'-u=-[Username]:username: ' \
'-e[Email]:email: ' \
'-p[Password]:password: ' \
'-u[Username]:username: ' \
':server: '
;;
(logs)
@@ -283,7 +336,7 @@ __docker_subcommand () {
'*:images:__docker_images'
;;
(restart|stop)
_arguments '-t=-[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \
_arguments '-t[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \
'*:containers:__docker_runningcontainers'
;;
(top)
@@ -302,7 +355,7 @@ __docker_subcommand () {
'-a[Show all containers]' \
'--before=-[Show only container created before...]:containers:__docker_containers' \
'-l[Show only the latest created container]' \
'-n=-[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' \
'-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' \
'--no-trunc[Do not truncate output]' \
'-q[Only show numeric IDs]' \
'-s[Display sizes]' \
@@ -318,28 +371,28 @@ __docker_subcommand () {
_arguments \
'-P[Publish all exposed ports to the host]' \
'-a[Attach to stdin, stdout or stderr]' \
'-c=-[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
'-c[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
'--cidfile=-[Write the container ID to the file]:CID file:_files' \
'-d[Detached mode: leave the container running in the background]' \
'*--dns=-[Set custom dns servers]:dns server: ' \
'*-e=-[Set environment variables]:environment variable: ' \
'*-e[Set environment variables]:environment variable: ' \
'--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \
'*--expose=-[Expose a port from the container without publishing it]: ' \
'-h=-[Container host name]:hostname:_hosts' \
'-h[Container host name]:hostname:_hosts' \
'-i[Keep stdin open even if not attached]' \
'--link=-[Add link to another container]:link:->link' \
'--lxc-conf=-[Add custom lxc options]:lxc options: ' \
'-m=-[Memory limit (in bytes)]:limit: ' \
'-m[Memory limit (in bytes)]:limit: ' \
'--name=-[Container name]:name: ' \
'*-p=-[Expose a container'"'"'s port to the host]:port:_ports' \
'*-p[Expose a container'"'"'s port to the host]:port:_ports' \
'--privileged[Give extended privileges to this container]' \
'--rm[Remove intermediate containers when it exits]' \
'--sig-proxy[Proxify all received signal]' \
'-t[Allocate a pseudo-tty]' \
'-u=-[Username or UID]:user:_users' \
'*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
'-u[Username or UID]:user:_users' \
'*-v[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
'--volumes-from=-[Mount volumes from the specified container]:volume: ' \
'-w=-[Working directory inside the container]:directory:_directories' \
'-w[Working directory inside the container]:directory:_directories' \
'(-):images:__docker_images' \
'(-):command: _command_names -e' \
'*::arguments: _normal'
@@ -359,7 +412,7 @@ __docker_subcommand () {
_arguments ':name:__docker_search'
;;
(push)
_arguments ':repository:__docker_repositories_with_tags'
_arguments ':images:__docker_images'
;;
(save)
_arguments \
@@ -389,7 +442,7 @@ _docker () {
typeset -A opt_args
_arguments -C \
'-H=-[tcp://host:port to bind/connect to]:socket: ' \
'-H[tcp://host:port to bind/connect to]:socket: ' \
'(-): :->command' \
'(-)*:: :->option-or-argument'
@@ -408,3 +461,11 @@ _docker () {
}
_docker "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 4
# indent-tabs-mode: nil
# sh-basic-offset: 4
# End:
# vim: ft=zsh sw=4 ts=4 et

View File

@@ -7,5 +7,5 @@ desktop applications.
Examples
========
* Data container: ./data/Dockerfile creates a data image sharing /data volume
* Iceweasel: ./iceweasel/Dockerfile shows a way to dockerize a common multimedia application
* Chromium: ./chromium/Dockerfile shows a way to dockerize a common application
* Gparted: ./gparted/Dockerfile shows a way to dockerize a common application w devices

View File

@@ -0,0 +1,38 @@
# VERSION: 0.1
# DESCRIPTION: Create chromium container with its dependencies
# AUTHOR: Jessica Frazelle <jess@docker.com>
# COMMENTS:
# This file describes how to build a Chromium container with all
# dependencies installed. It uses native X11 unix socket.
# Tested on Debian Jessie
# USAGE:
# # Download Chromium Dockerfile
# wget http://raw.githubusercontent.com/docker/docker/master/contrib/desktop-integration/chromium/Dockerfile
#
# # Build chromium image
# docker build -t chromium .
#
# # Run stateful data-on-host chromium. For ephemeral, remove -v /data/chromium:/data
# docker run -v /data/chromium:/data -v /tmp/.X11-unix:/tmp/.X11-unix \
# -e DISPLAY=unix$DISPLAY chromium
# # To run stateful dockerized data containers
# docker run --volumes-from chromium-data -v /tmp/.X11-unix:/tmp/.X11-unix \
# -e DISPLAY=unix$DISPLAY chromium
DOCKER_VERSION 1.3
# Base docker image
FROM debian:jessie
MAINTAINER Jessica Frazelle <jess@docker.com>
# Install Chromium
RUN apt-get update && apt-get install -y \
chromium \
chromium-l10n \
libcanberra-gtk-module \
libexif-dev \
--no-install-recommends
# Autorun chromium
CMD ["/usr/bin/chromium", "--no-sandbox", "--user-data-dir=/data"]

View File

@@ -1,38 +0,0 @@
# VERSION: 0.1
# DESCRIPTION: Create data image sharing /data volume
# AUTHOR: Daniel Mizyrycki <daniel@dotcloud.com>
# COMMENTS:
# This image is used as base for all data containers.
# /data volume is owned by sysadmin.
# USAGE:
# # Download data Dockerfile
# wget http://raw.githubusercontent.com/dotcloud/docker/master/contrib/desktop-integration/data/Dockerfile
#
# # Build data image
# docker build -t data .
#
# # Create a data container. (eg: iceweasel-data)
# docker run --name iceweasel-data data true
#
# # List data from it
# docker run --volumes-from iceweasel-data busybox ls -al /data
docker-version 0.6.5
# Smallest base image, just to launch a container
FROM busybox
MAINTAINER Daniel Mizyrycki <daniel@docker.com>
# Create a regular user
RUN echo 'sysadmin:x:1000:1000::/data:/bin/sh' >> /etc/passwd
RUN echo 'sysadmin:x:1000:' >> /etc/group
# Create directory for that user
RUN mkdir /data
RUN chown sysadmin.sysadmin /data
# Add content to /data. This will keep sysadmin ownership
RUN touch /data/init_volume
# Create /data volume
VOLUME /data

View File

@@ -0,0 +1,33 @@
# VERSION: 0.1
# DESCRIPTION: Create gparted container with its dependencies
# AUTHOR: Jessica Frazelle <jess@docker.com>
# COMMENTS:
# This file describes how to build a gparted container with all
# dependencies installed. It uses native X11 unix socket.
# Tested on Debian Jessie
# USAGE:
# # Download gparted Dockerfile
# wget http://raw.githubusercontent.com/docker/docker/master/contrib/desktop-integration/gparted/Dockerfile
#
# # Build gparted image
# docker build -t gparted .
#
# docker run -v /tmp/.X11-unix:/tmp/.X11-unix \
# --device=/dev/sda:/dev/sda \
# -e DISPLAY=unix$DISPLAY gparted
#
DOCKER-VERSION 1.3
# Base docker image
FROM debian:jessie
MAINTAINER Jessica Frazelle <jess@docker.com>
# Install Gparted and its dependencies
RUN apt-get update && apt-get install -y \
gparted \
libcanberra-gtk-module \
--no-install-recommends
# Autorun gparted
CMD ["/usr/sbin/gparted"]

View File

@@ -1,41 +0,0 @@
# VERSION: 0.7
# DESCRIPTION: Create iceweasel container with its dependencies
# AUTHOR: Daniel Mizyrycki <daniel@dotcloud.com>
# COMMENTS:
# This file describes how to build a Iceweasel container with all
# dependencies installed. It uses native X11 unix socket and alsa
# sound devices. Tested on Debian 7.2
# USAGE:
# # Download Iceweasel Dockerfile
# wget http://raw.githubusercontent.com/dotcloud/docker/master/contrib/desktop-integration/iceweasel/Dockerfile
#
# # Build iceweasel image
# docker build -t iceweasel .
#
# # Run stateful data-on-host iceweasel. For ephemeral, remove -v /data/iceweasel:/data
# docker run -v /data/iceweasel:/data -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /dev/snd:/dev/snd --lxc-conf='lxc.cgroup.devices.allow = c 116:* rwm' \
# -e DISPLAY=unix$DISPLAY iceweasel
#
# # To run stateful dockerized data containers
# docker run --volumes-from iceweasel-data -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /dev/snd:/dev/snd --lxc-conf='lxc.cgroup.devices.allow = c 116:* rwm' \
# -e DISPLAY=unix$DISPLAY iceweasel
docker-version 0.6.5
# Base docker image
FROM debian:wheezy
MAINTAINER Daniel Mizyrycki <daniel@docker.com>
# Install Iceweasel and "sudo"
RUN apt-get update && apt-get install -y iceweasel sudo
# create sysadmin account
RUN useradd -m -d /data -p saIVpsc0EVTwA sysadmin
RUN sed -Ei 's/sudo:x:27:/sudo:x:27:sysadmin/' /etc/group
RUN sed -Ei 's/(\%sudo\s+ALL=\(ALL\:ALL\) )ALL/\1 NOPASSWD:ALL/' /etc/sudoers
# Autorun iceweasel. -no-remote is necessary to create a new container, as
# iceweasel appears to communicate with itself through X11.
CMD ["/usr/bin/sudo", "-u", "sysadmin", "-H", "-E", "/usr/bin/iceweasel", "-no-remote"]

View File

@@ -10,4 +10,4 @@ LimitNOFILE=1048576
LimitNPROC=1048576
[Install]
Also=docker.socket
WantedBy=multi-user.target

View File

@@ -1,5 +1,6 @@
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock

View File

@@ -68,7 +68,7 @@ start() {
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
killproc -p $pidfile -d 300 $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile

View File

@@ -6,7 +6,7 @@ mkimg="$(basename "$0")"
usage() {
echo >&2 "usage: $mkimg [-d dir] [-t tag] script [script-args]"
echo >&2 " ie: $mkimg -t someuser/debian debootstrap --variant=minbase jessie"
echo >&2 " $mkimg -t someuser/ubuntu debootstrap --include=ubuntu-minimal --components main,universe trusty"
echo >&2 " $mkimg -t someuser/ubuntu debootstrap --include=ubuntu-minimal --components=main,universe trusty"
echo >&2 " $mkimg -t someuser/busybox busybox-static"
echo >&2 " $mkimg -t someuser/centos:5 rinse --distribution centos-5"
echo >&2 " $mkimg -t someuser/mageia:4 mageia-urpmi --version=4"

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!-- Dockerfile syntaxfile v1.0 by James Turnbull <james@lovedthanlost.net> -->
<language name="Dockerfile" section="Other"
version="1.0" kateversion="2.4"
extensions="Dockerfile"
mimetype="text/plain"
author="James Turnbull (james@lovedthanlost.net)"
license="GPL">
<highlighting>
<list name="keywords">
<item> FROM </item>
<item> MAINTAINER </item>
<item> ENV </item>
<item> RUN </item>
<item> ONBUILD </item>
<item> COPY </item>
<item> ADD </item>
<item> VOLUME </item>
<item> EXPOSE </item>
<item> ENTRYPOINT </item>
<item> CMD </item>
<item> WORKDIR </item>
<item> USER </item>
</list>
<contexts>
<context name="normal" attribute="Normal" lineEndContext="#stay">
<DetectSpaces/>
<DetectChar attribute="Comment" context="Comment" char="#"/>
<keyword attribute="Keyword" context="#stay" String="keywords"/>
<DetectIdentifier/>
<DetectChar attribute="String" context="string&quot;" char="&quot;"/>
<DetectChar attribute="String" context="string'" char="'"/>
</context>
<context attribute="Comment" lineEndContext="#pop" name="Comment">
<LineContinue attribute="Comment" context="#stay" />
</context>
<context name="string&quot;" attribute="String" lineEndContext="#pop">
<LineContinue attribute="Operator" context="#stay"/>
<DetectChar attribute="String" context="#pop" char="&quot;"/>
<DetectChar attribute="Operator" context="dollar" char="$"/>
</context>
<context name="string'" attribute="String" lineEndContext="#pop">
<LineContinue attribute="String" context="#stay"/>
<DetectChar attribute="String" context="#pop" char="'"/>
<DetectChar attribute="Operator" context="dollar" char="$"/>
</context>
</contexts>
<itemDatas>
<itemData name="Normal" defStyleNum="dsNormal" spellChecking="0"/>
<itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="0"/>
<itemData name="Comment" defStyleNum="dsComment"/>
<itemData name="String" defStyleNum="dsString" spellChecking="0"/>
</itemDatas>
</highlighting>
<general>
<comments>
<comment name = "singleLine" start = "#"/>
</comments>
</general>
</language>
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->

View File

@@ -2,14 +2,15 @@ package daemon
import (
"encoding/json"
"fmt"
"io"
"os"
"time"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/jsonlog"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/utils"
)
@@ -68,10 +69,10 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
break
}
if l.Stream == "stdout" && stdout {
fmt.Fprintf(job.Stdout, "%s", l.Log)
io.WriteString(job.Stdout, l.Log)
}
if l.Stream == "stderr" && stderr {
fmt.Fprintf(job.Stderr, "%s", l.Log)
io.WriteString(job.Stderr, l.Log)
}
}
}
@@ -102,12 +103,11 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
cStderr = job.Stderr
}
<-daemon.Attach(container, cStdin, cStdinCloser, cStdout, cStderr)
<-daemon.Attach(&container.StreamConfig, container.Config.OpenStdin, container.Config.StdinOnce, container.Config.Tty, cStdin, cStdinCloser, cStdout, cStderr)
// If we are in stdinonce mode, wait for the process to end
// otherwise, simply return
if container.Config.StdinOnce && !container.Config.Tty {
container.State.WaitStop(-1 * time.Second)
container.WaitStop(-1 * time.Second)
}
}
return engine.StatusOK
@@ -115,27 +115,29 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
// FIXME: this should be private, and every outside subsystem
// should go through the "container_attach" job. But that would require
// that job to be properly documented, as well as the relationship betweem
// that job to be properly documented, as well as the relationship between
// Attach and ContainerAttach.
//
// This method is in use by builder/builder.go.
func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinCloser io.Closer, stdout io.Writer, stderr io.Writer) chan error {
func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdinCloser io.Closer, stdout io.Writer, stderr io.Writer) chan error {
var (
cStdout, cStderr io.ReadCloser
nJobs int
errors = make(chan error, 3)
)
if stdin != nil && container.Config.OpenStdin {
nJobs += 1
if cStdin, err := container.StdinPipe(); err != nil {
// Connect stdin of container to the http conn.
if stdin != nil && openStdin {
nJobs++
// Get the stdin pipe.
if cStdin, err := streamConfig.StdinPipe(); err != nil {
errors <- err
} else {
go func() {
log.Debugf("attach: stdin: begin")
defer log.Debugf("attach: stdin: end")
// No matter what, when stdin is closed (io.Copy unblock), close stdout and stderr
if container.Config.StdinOnce && !container.Config.Tty {
if stdinOnce && !tty {
defer cStdin.Close()
} else {
defer func() {
@@ -147,10 +149,11 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
}
}()
}
if container.Config.Tty {
if tty {
_, err = utils.CopyEscapable(cStdin, stdin)
} else {
_, err = io.Copy(cStdin, stdin)
}
if err == io.ErrClosedPipe {
err = nil
@@ -163,8 +166,9 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
}
}
if stdout != nil {
nJobs += 1
if p, err := container.StdoutPipe(); err != nil {
nJobs++
// Get a reader end of a pipe that is attached as stdout to the container.
if p, err := streamConfig.StdoutPipe(); err != nil {
errors <- err
} else {
cStdout = p
@@ -172,7 +176,7 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
log.Debugf("attach: stdout: begin")
defer log.Debugf("attach: stdout: end")
// If we are in StdinOnce mode, then close stdin
if container.Config.StdinOnce && stdin != nil {
if stdinOnce && stdin != nil {
defer stdin.Close()
}
if stdinCloser != nil {
@@ -189,20 +193,21 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
}()
}
} else {
// Point stdout of container to a no-op writer.
go func() {
if stdinCloser != nil {
defer stdinCloser.Close()
}
if cStdout, err := container.StdoutPipe(); err != nil {
if cStdout, err := streamConfig.StdoutPipe(); err != nil {
log.Errorf("attach: stdout pipe: %s", err)
} else {
io.Copy(&utils.NopWriter{}, cStdout)
io.Copy(&ioutils.NopWriter{}, cStdout)
}
}()
}
if stderr != nil {
nJobs += 1
if p, err := container.StderrPipe(); err != nil {
nJobs++
if p, err := streamConfig.StderrPipe(); err != nil {
errors <- err
} else {
cStderr = p
@@ -210,7 +215,8 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
log.Debugf("attach: stderr: begin")
defer log.Debugf("attach: stderr: end")
// If we are in StdinOnce mode, then close stdin
if container.Config.StdinOnce && stdin != nil {
// Why are we closing stdin here and above while handling stdout?
if stdinOnce && stdin != nil {
defer stdin.Close()
}
if stdinCloser != nil {
@@ -227,20 +233,21 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
}()
}
} else {
// Point stderr at a no-op writer.
go func() {
if stdinCloser != nil {
defer stdinCloser.Close()
}
if cStderr, err := container.StderrPipe(); err != nil {
if cStderr, err := streamConfig.StderrPipe(); err != nil {
log.Errorf("attach: stdout pipe: %s", err)
} else {
io.Copy(&utils.NopWriter{}, cStderr)
io.Copy(&ioutils.NopWriter{}, cStderr)
}
}()
}
return utils.Go(func() error {
return promise.Go(func() error {
defer func() {
if cStdout != nil {
cStdout.Close()
@@ -252,7 +259,7 @@ func (daemon *Daemon) Attach(container *Container, stdin io.ReadCloser, stdinClo
// FIXME: how to clean up the stdin goroutine without the unwanted side effect
// of closing the passed stdin? Add an intermediary io.Pipe?
for i := 0; i < nJobs; i += 1 {
for i := 0; i < nJobs; i++ {
log.Debugf("attach: waiting for job %d/%d", i+1, nJobs)
if err := <-errors; err != nil {
log.Errorf("attach: job %d returned error %s, aborting all jobs", i+1, err)

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ import (
const (
defaultNetworkMtu = 1500
DisableNetworkBridge = "none"
disableNetworkBridge = "none"
)
// Config define the configuration of a docker daemon
@@ -23,11 +23,15 @@ type Config struct {
AutoRestart bool
Dns []string
DnsSearch []string
Mirrors []string
EnableIptables bool
EnableIpForward bool
EnableIpMasq bool
DefaultIp net.IP
BridgeIface string
BridgeIP string
FixedCIDR string
InsecureRegistries []string
InterContainerCommunication bool
GraphDriver string
GraphOptions []string
@@ -45,11 +49,14 @@ type Config struct {
func (config *Config) InstallFlags() {
flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime")
flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated infavor of --restart policies on docker run")
flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
flag.BoolVar(&config.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules")
flag.BoolVar(&config.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
flag.BoolVar(&config.EnableIpMasq, []string{"-ip-masq"}, true, "Enable IP masquerading for bridge's IP range")
flag.StringVar(&config.BridgeIP, []string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b")
flag.StringVar(&config.BridgeIface, []string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking")
flag.StringVar(&config.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs (ex: 10.20.0.0/16)\nthis subnet must be nested in the bridge subnet (which is defined by -b or --bip)")
opts.ListVar(&config.InsecureRegistries, []string{"-insecure-registry"}, "Enable insecure communication with specified registries (no certificate verification for HTTPS and enable HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16)")
flag.BoolVar(&config.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Enable inter-container communication")
flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Force the Docker runtime to use a specific storage driver")
flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, "native", "Force the Docker runtime to use a specific exec driver")
@@ -60,6 +67,15 @@ func (config *Config) InstallFlags() {
// FIXME: why the inconsistency between "hosts" and "sockets"?
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
opts.MirrorListVar(&config.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror")
// Localhost is by default considered as an insecure registry
// This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker).
//
// TODO: should we deprecate this once it is easier for people to set up a TLS registry or change
// daemon flags on boot2docker?
// If so, do not forget to check the TODO in TestIsSecure
config.InsecureRegistries = append(config.InsecureRegistries, "127.0.0.0/8")
}
func GetDefaultNetworkMtu() int {

View File

@@ -1,6 +1,7 @@
package daemon
import (
"bytes"
"encoding/json"
"errors"
"fmt"
@@ -10,24 +11,24 @@ import (
"path"
"path/filepath"
"strings"
"sync"
"syscall"
"time"
"github.com/docker/libcontainer/devices"
"github.com/docker/libcontainer/label"
"github.com/docker/docker/archive"
"github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/engine"
"github.com/docker/docker/image"
"github.com/docker/docker/links"
"github.com/docker/docker/nat"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/broadcastwriter"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/networkfs/etchosts"
"github.com/docker/docker/pkg/networkfs/resolvconf"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/pkg/symlink"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/utils"
@@ -42,10 +43,17 @@ var (
ErrContainerStartTimeout = errors.New("The container failed to start due to timed out.")
)
type StreamConfig struct {
stdout *broadcastwriter.BroadcastWriter
stderr *broadcastwriter.BroadcastWriter
stdin io.ReadCloser
stdinPipe io.WriteCloser
}
type Container struct {
sync.Mutex
root string // Path to the "home" of the container, including metadata.
basefs string // Path to the graphdriver mountpoint
*State `json:"State"` // Needed for remote api version <= 1.11
root string // Path to the "home" of the container, including metadata.
basefs string // Path to the graphdriver mountpoint
ID string
@@ -55,7 +63,6 @@ type Container struct {
Args []string
Config *runconfig.Config
State *State
Image string
NetworkSettings *NetworkSettings
@@ -67,24 +74,26 @@ type Container struct {
Driver string
ExecDriver string
command *execdriver.Command
stdout *broadcastwriter.BroadcastWriter
stderr *broadcastwriter.BroadcastWriter
stdin io.ReadCloser
stdinPipe io.WriteCloser
command *execdriver.Command
StreamConfig
daemon *Daemon
MountLabel, ProcessLabel string
AppArmorProfile string
RestartCount int
// Maps container paths to volume paths. The key in this is the path to which
// the volume is being mounted inside the container. Value is the path of the
// volume on disk
Volumes map[string]string
// Store rw/ro in a separate structure to preserve reverse-compatibility on-disk.
// Easier than migrating older container configs :)
VolumesRW map[string]bool
hostConfig *runconfig.HostConfig
activeLinks map[string]*links.Link
monitor *containerMonitor
activeLinks map[string]*links.Link
monitor *containerMonitor
execCommands *execStore
}
func (container *Container) FromDisk() error {
@@ -189,14 +198,7 @@ func (container *Container) getRootResourcePath(path string) (string, error) {
}
func populateCommand(c *Container, env []string) error {
var (
en *execdriver.Network
context = make(map[string][]string)
)
context["process_label"] = []string{c.GetProcessLabel()}
context["mount_label"] = []string{c.GetMountLabel()}
en = &execdriver.Network{
en := &execdriver.Network{
Mtu: c.daemon.config.Mtu,
Interface: nil,
}
@@ -214,6 +216,7 @@ func populateCommand(c *Container, env []string) error {
Bridge: network.Bridge,
IPAddress: network.IPAddress,
IPPrefixLen: network.IPPrefixLen,
MacAddress: network.MacAddress,
}
}
case "container":
@@ -230,10 +233,10 @@ func populateCommand(c *Container, env []string) error {
userSpecifiedDevices := make([]*devices.Device, len(c.hostConfig.Devices))
for i, deviceMapping := range c.hostConfig.Devices {
device, err := devices.GetDevice(deviceMapping.PathOnHost, deviceMapping.CgroupPermissions)
device.Path = deviceMapping.PathInContainer
if err != nil {
return fmt.Errorf("error gathering device information while adding custom device %s", err)
return fmt.Errorf("error gathering device information while adding custom device %q: %s", deviceMapping.PathOnHost, err)
}
device.Path = deviceMapping.PathInContainer
userSpecifiedDevices[i] = device
}
allowedDevices := append(devices.DefaultAllowedDevices, userSpecifiedDevices...)
@@ -241,7 +244,7 @@ func populateCommand(c *Container, env []string) error {
autoCreatedDevices := append(devices.DefaultAutoCreatedDevices, userSpecifiedDevices...)
// TODO: this can be removed after lxc-conf is fully deprecated
mergeLxcConfIntoOptions(c.hostConfig, context)
lxcConfig := mergeLxcConfIntoOptions(c.hostConfig)
resources := &execdriver.Resources{
Memory: c.Config.Memory,
@@ -249,26 +252,36 @@ func populateCommand(c *Container, env []string) error {
CpuShares: c.Config.CpuShares,
Cpuset: c.Config.Cpuset,
}
processConfig := execdriver.ProcessConfig{
Privileged: c.hostConfig.Privileged,
Entrypoint: c.Path,
Arguments: c.Args,
Tty: c.Config.Tty,
User: c.Config.User,
}
processConfig.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
processConfig.Env = env
c.command = &execdriver.Command{
ID: c.ID,
Privileged: c.hostConfig.Privileged,
Rootfs: c.RootfsPath(),
InitPath: "/.dockerinit",
Entrypoint: c.Path,
Arguments: c.Args,
WorkingDir: c.Config.WorkingDir,
Network: en,
Tty: c.Config.Tty,
User: c.Config.User,
Config: context,
Resources: resources,
AllowedDevices: allowedDevices,
AutoCreatedDevices: autoCreatedDevices,
CapAdd: c.hostConfig.CapAdd,
CapDrop: c.hostConfig.CapDrop,
ProcessConfig: processConfig,
ProcessLabel: c.GetProcessLabel(),
MountLabel: c.GetMountLabel(),
LxcConfig: lxcConfig,
AppArmorProfile: c.AppArmorProfile,
}
c.command.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
c.command.Env = env
return nil
}
@@ -276,7 +289,7 @@ func (container *Container) Start() (err error) {
container.Lock()
defer container.Unlock()
if container.State.IsRunning() {
if container.Running {
return nil
}
@@ -297,8 +310,11 @@ func (container *Container) Start() (err error) {
if err := container.initializeNetworking(); err != nil {
return err
}
if err := container.updateParentsHosts(); err != nil {
return err
}
container.verifyDaemonSettings()
if err := prepareVolumesForContainer(container); err != nil {
if err := container.prepareVolumes(); err != nil {
return err
}
linkedEnv, err := container.setupLinkedContainers()
@@ -312,7 +328,7 @@ func (container *Container) Start() (err error) {
if err := populateCommand(container, env); err != nil {
return err
}
if err := setupMountsForContainer(container); err != nil {
if err := container.setupMounts(); err != nil {
return err
}
@@ -323,7 +339,7 @@ func (container *Container) Run() error {
if err := container.Start(); err != nil {
return err
}
container.State.WaitStop(-1 * time.Second)
container.WaitStop(-1 * time.Second)
return nil
}
@@ -337,11 +353,11 @@ func (container *Container) Output() (output []byte, err error) {
return nil, err
}
output, err = ioutil.ReadAll(pipe)
container.State.WaitStop(-1 * time.Second)
container.WaitStop(-1 * time.Second)
return output, err
}
// Container.StdinPipe returns a WriteCloser which can be used to feed data
// StreamConfig.StdinPipe returns a WriteCloser which can be used to feed data
// to the standard input of the container's active process.
// Container.StdoutPipe and Container.StderrPipe each return a ReadCloser
// which can be used to retrieve the standard output (and error) generated
@@ -349,32 +365,32 @@ func (container *Container) Output() (output []byte, err error) {
// copied and delivered to all StdoutPipe and StderrPipe consumers, using
// a kind of "broadcaster".
func (container *Container) StdinPipe() (io.WriteCloser, error) {
return container.stdinPipe, nil
func (streamConfig *StreamConfig) StdinPipe() (io.WriteCloser, error) {
return streamConfig.stdinPipe, nil
}
func (container *Container) StdoutPipe() (io.ReadCloser, error) {
func (streamConfig *StreamConfig) StdoutPipe() (io.ReadCloser, error) {
reader, writer := io.Pipe()
container.stdout.AddWriter(writer, "")
return utils.NewBufReader(reader), nil
streamConfig.stdout.AddWriter(writer, "")
return ioutils.NewBufReader(reader), nil
}
func (container *Container) StderrPipe() (io.ReadCloser, error) {
func (streamConfig *StreamConfig) StderrPipe() (io.ReadCloser, error) {
reader, writer := io.Pipe()
container.stderr.AddWriter(writer, "")
return utils.NewBufReader(reader), nil
streamConfig.stderr.AddWriter(writer, "")
return ioutils.NewBufReader(reader), nil
}
func (container *Container) StdoutLogPipe() io.ReadCloser {
func (streamConfig *StreamConfig) StdoutLogPipe() io.ReadCloser {
reader, writer := io.Pipe()
container.stdout.AddWriter(writer, "stdout")
return utils.NewBufReader(reader)
streamConfig.stdout.AddWriter(writer, "stdout")
return ioutils.NewBufReader(reader)
}
func (container *Container) StderrLogPipe() io.ReadCloser {
func (streamConfig *StreamConfig) StderrLogPipe() io.ReadCloser {
reader, writer := io.Pipe()
container.stderr.AddWriter(writer, "stderr")
return utils.NewBufReader(reader)
streamConfig.stderr.AddWriter(writer, "stderr")
return ioutils.NewBufReader(reader)
}
func (container *Container) buildHostnameFile() error {
@@ -390,10 +406,7 @@ func (container *Container) buildHostnameFile() error {
return ioutil.WriteFile(container.HostnamePath, []byte(container.Config.Hostname+"\n"), 0644)
}
func (container *Container) buildHostnameAndHostsFiles(IP string) error {
if err := container.buildHostnameFile(); err != nil {
return err
}
func (container *Container) buildHostsFiles(IP string) error {
hostsPath, err := container.getRootResourcePath("hosts")
if err != nil {
@@ -413,12 +426,25 @@ func (container *Container) buildHostnameAndHostsFiles(IP string) error {
extraContent[alias] = child.NetworkSettings.IPAddress
}
for _, extraHost := range container.hostConfig.ExtraHosts {
parts := strings.Split(extraHost, ":")
extraContent[parts[0]] = parts[1]
}
return etchosts.Build(container.HostsPath, IP, container.Config.Hostname, container.Config.Domainname, &extraContent)
}
func (container *Container) allocateNetwork() error {
func (container *Container) buildHostnameAndHostsFiles(IP string) error {
if err := container.buildHostnameFile(); err != nil {
return err
}
return container.buildHostsFiles(IP)
}
func (container *Container) AllocateNetwork() error {
mode := container.hostConfig.NetworkMode
if container.Config.NetworkDisabled || mode.IsContainer() || mode.IsHost() {
if container.Config.NetworkDisabled || !mode.IsPrivate() {
return nil
}
@@ -432,16 +458,22 @@ func (container *Container) allocateNetwork() error {
if env, err = job.Stdout.AddEnv(); err != nil {
return err
}
if err := job.Run(); err != nil {
if err = job.Run(); err != nil {
return err
}
// Error handling: At this point, the interface is allocated so we have to
// make sure that it is always released in case of error, otherwise we
// might leak resources.
if container.Config.PortSpecs != nil {
if err := migratePortMappings(container.Config, container.hostConfig); err != nil {
if err = migratePortMappings(container.Config, container.hostConfig); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
container.Config.PortSpecs = nil
if err := container.WriteHostConfig(); err != nil {
if err = container.WriteHostConfig(); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
}
@@ -470,7 +502,8 @@ func (container *Container) allocateNetwork() error {
container.NetworkSettings.PortMapping = nil
for port := range portSpecs {
if err := container.allocatePort(eng, port, bindings); err != nil {
if err = container.allocatePort(eng, port, bindings); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
}
@@ -480,12 +513,13 @@ func (container *Container) allocateNetwork() error {
container.NetworkSettings.Bridge = env.Get("Bridge")
container.NetworkSettings.IPAddress = env.Get("IP")
container.NetworkSettings.IPPrefixLen = env.GetInt("IPPrefixLen")
container.NetworkSettings.MacAddress = env.Get("MacAddress")
container.NetworkSettings.Gateway = env.Get("Gateway")
return nil
}
func (container *Container) releaseNetwork() {
func (container *Container) ReleaseNetwork() {
if container.Config.NetworkDisabled {
return
}
@@ -495,10 +529,42 @@ func (container *Container) releaseNetwork() {
container.NetworkSettings = &NetworkSettings{}
}
func (container *Container) isNetworkAllocated() bool {
return container.NetworkSettings.IPAddress != ""
}
func (container *Container) RestoreNetwork() error {
mode := container.hostConfig.NetworkMode
// Don't attempt a restore if we previously didn't allocate networking.
// This might be a legacy container with no network allocated, in which case the
// allocation will happen once and for all at start.
if !container.isNetworkAllocated() || container.Config.NetworkDisabled || !mode.IsPrivate() {
return nil
}
eng := container.daemon.eng
// Re-allocate the interface with the same IP and MAC address.
job := eng.Job("allocate_interface", container.ID)
job.Setenv("RequestedIP", container.NetworkSettings.IPAddress)
job.Setenv("RequestedMac", container.NetworkSettings.MacAddress)
if err := job.Run(); err != nil {
return err
}
// Re-allocate any previously allocated ports.
for port := range container.NetworkSettings.Ports {
if err := container.allocatePort(eng, port, container.NetworkSettings.Ports); err != nil {
return err
}
}
return nil
}
// cleanup releases any network resources allocated to the container along with any rules
// around how containers are linked together. It also unmounts the container's root filesystem.
func (container *Container) cleanup() {
container.releaseNetwork()
container.ReleaseNetwork()
// Disable all active links
if container.activeLinks != nil {
@@ -518,11 +584,11 @@ func (container *Container) KillSig(sig int) error {
defer container.Unlock()
// We could unpause the container for them rather than returning this error
if container.State.IsPaused() {
if container.Paused {
return fmt.Errorf("Container %s is paused. Unpause the container before stopping", container.ID)
}
if !container.State.IsRunning() {
if !container.Running {
return nil
}
@@ -533,7 +599,7 @@ func (container *Container) KillSig(sig int) error {
// if the container is currently restarting we do not need to send the signal
// to the process. Telling the monitor that it should exit on it's next event
// loop is enough
if container.State.IsRestarting() {
if container.Restarting {
return nil
}
@@ -541,27 +607,27 @@ func (container *Container) KillSig(sig int) error {
}
func (container *Container) Pause() error {
if container.State.IsPaused() {
if container.IsPaused() {
return fmt.Errorf("Container %s is already paused", container.ID)
}
if !container.State.IsRunning() {
if !container.IsRunning() {
return fmt.Errorf("Container %s is not running", container.ID)
}
return container.daemon.Pause(container)
}
func (container *Container) Unpause() error {
if !container.State.IsPaused() {
if !container.IsPaused() {
return fmt.Errorf("Container %s is not paused", container.ID)
}
if !container.State.IsRunning() {
if !container.IsRunning() {
return fmt.Errorf("Container %s is not running", container.ID)
}
return container.daemon.Unpause(container)
}
func (container *Container) Kill() error {
if !container.State.IsRunning() {
if !container.IsRunning() {
return nil
}
@@ -571,9 +637,9 @@ func (container *Container) Kill() error {
}
// 2. Wait for the process to die, in last resort, try to kill the process directly
if _, err := container.State.WaitStop(10 * time.Second); err != nil {
if _, err := container.WaitStop(10 * time.Second); err != nil {
// Ensure that we don't kill ourselves
if pid := container.State.GetPid(); pid != 0 {
if pid := container.GetPid(); pid != 0 {
log.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", utils.TruncateID(container.ID))
if err := syscall.Kill(pid, 9); err != nil {
return err
@@ -581,12 +647,12 @@ func (container *Container) Kill() error {
}
}
container.State.WaitStop(-1 * time.Second)
container.WaitStop(-1 * time.Second)
return nil
}
func (container *Container) Stop(seconds int) error {
if !container.State.IsRunning() {
if !container.IsRunning() {
return nil
}
@@ -599,11 +665,11 @@ func (container *Container) Stop(seconds int) error {
}
// 2. Wait for the process to exit on its own
if _, err := container.State.WaitStop(time.Duration(seconds) * time.Second); err != nil {
if _, err := container.WaitStop(time.Duration(seconds) * time.Second); err != nil {
log.Infof("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds)
// 3. If it doesn't, then send SIGKILL
if err := container.Kill(); err != nil {
container.State.WaitStop(-1 * time.Second)
container.WaitStop(-1 * time.Second)
return err
}
}
@@ -625,7 +691,7 @@ func (container *Container) Restart(seconds int) error {
}
func (container *Container) Resize(h, w int) error {
return container.command.Terminal.Resize(h, w)
return container.command.ProcessConfig.Terminal.Resize(h, w)
}
func (container *Container) ExportRw() (archive.Archive, error) {
@@ -640,7 +706,7 @@ func (container *Container) ExportRw() (archive.Archive, error) {
container.Unmount()
return nil, err
}
return utils.NewReadCloserWrapper(archive, func() error {
return ioutils.NewReadCloserWrapper(archive, func() error {
err := archive.Close()
container.Unmount()
return err
@@ -658,7 +724,7 @@ func (container *Container) Export() (archive.Archive, error) {
container.Unmount()
return nil, err
}
return utils.NewReadCloserWrapper(archive, func() error {
return ioutils.NewReadCloserWrapper(archive, func() error {
err := archive.Close()
container.Unmount()
return err
@@ -670,10 +736,14 @@ func (container *Container) Mount() error {
return container.daemon.Mount(container)
}
func (container *Container) changes() ([]archive.Change, error) {
return container.daemon.Changes(container)
}
func (container *Container) Changes() ([]archive.Change, error) {
container.Lock()
defer container.Unlock()
return container.daemon.Changes(container)
return container.changes()
}
func (container *Container) GetImage() (*image.Image, error) {
@@ -734,21 +804,13 @@ func (container *Container) GetSize() (int64, int64) {
}
defer container.Unmount()
if differ, ok := container.daemon.driver.(graphdriver.Differ); ok {
sizeRw, err = differ.DiffSize(container.ID)
if err != nil {
log.Errorf("Warning: driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
// FIXME: GetSize should return an error. Not changing it now in case
// there is a side-effect.
sizeRw = -1
}
} else {
changes, _ := container.Changes()
if changes != nil {
sizeRw = archive.ChangesSize(container.basefs, changes)
} else {
sizeRw = -1
}
initID := fmt.Sprintf("%s-init", container.ID)
sizeRw, err = driver.DiffSize(container.ID, initID)
if err != nil {
log.Errorf("Warning: driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
// FIXME: GetSize should return an error. Not changing it now in case
// there is a side-effect.
sizeRw = -1
}
if _, err = os.Stat(container.basefs); err != nil {
@@ -794,7 +856,7 @@ func (container *Container) Copy(resource string) (io.ReadCloser, error) {
container.Unmount()
return nil, err
}
return utils.NewReadCloserWrapper(archive, func() error {
return ioutils.NewReadCloserWrapper(archive, func() error {
err := archive.Close()
container.Unmount()
return err
@@ -809,7 +871,7 @@ func (container *Container) Exposes(p nat.Port) bool {
}
func (container *Container) GetPtyMaster() (*os.File, error) {
ttyConsole, ok := container.command.Terminal.(execdriver.TtyTerminal)
ttyConsole, ok := container.command.ProcessConfig.Terminal.(execdriver.TtyTerminal)
if !ok {
return nil, ErrNoTTY
}
@@ -858,26 +920,58 @@ func (container *Container) setupContainerDns() error {
return err
}
if config.NetworkMode != "host" && (len(config.Dns) > 0 || len(daemon.config.Dns) > 0 || len(config.DnsSearch) > 0 || len(daemon.config.DnsSearch) > 0) {
var (
dns = resolvconf.GetNameservers(resolvConf)
dnsSearch = resolvconf.GetSearchDomains(resolvConf)
)
if len(config.Dns) > 0 {
dns = config.Dns
} else if len(daemon.config.Dns) > 0 {
dns = daemon.config.Dns
if config.NetworkMode != "host" {
// check configurations for any container/daemon dns settings
if len(config.Dns) > 0 || len(daemon.config.Dns) > 0 || len(config.DnsSearch) > 0 || len(daemon.config.DnsSearch) > 0 {
var (
dns = resolvconf.GetNameservers(resolvConf)
dnsSearch = resolvconf.GetSearchDomains(resolvConf)
)
if len(config.Dns) > 0 {
dns = config.Dns
} else if len(daemon.config.Dns) > 0 {
dns = daemon.config.Dns
}
if len(config.DnsSearch) > 0 {
dnsSearch = config.DnsSearch
} else if len(daemon.config.DnsSearch) > 0 {
dnsSearch = daemon.config.DnsSearch
}
return resolvconf.Build(container.ResolvConfPath, dns, dnsSearch)
}
if len(config.DnsSearch) > 0 {
dnsSearch = config.DnsSearch
} else if len(daemon.config.DnsSearch) > 0 {
dnsSearch = daemon.config.DnsSearch
// replace any localhost/127.* nameservers
resolvConf = utils.RemoveLocalDns(resolvConf)
// if the resulting resolvConf is empty, use DefaultDns
if !bytes.Contains(resolvConf, []byte("nameserver")) {
log.Infof("No non localhost DNS resolver found in resolv.conf and containers can't use it. Using default external servers : %v", DefaultDns)
// prefix the default dns options with nameserver
resolvConf = append(resolvConf, []byte("\nnameserver "+strings.Join(DefaultDns, "\nnameserver "))...)
}
return resolvconf.Build(container.ResolvConfPath, dns, dnsSearch)
}
return ioutil.WriteFile(container.ResolvConfPath, resolvConf, 0644)
}
func (container *Container) updateParentsHosts() error {
parents, err := container.daemon.Parents(container.Name)
if err != nil {
return err
}
for _, cid := range parents {
if cid == "0" {
continue
}
c := container.daemon.Get(cid)
if c != nil && !container.daemon.config.DisableNetwork && container.hostConfig.NetworkMode.IsPrivate() {
if err := etchosts.Update(c.HostsPath, container.NetworkSettings.IPAddress, container.Name[1:]); err != nil {
return fmt.Errorf("Failed to update /etc/hosts in parent container: %v", err)
}
}
}
return nil
}
func (container *Container) initializeNetworking() error {
var err error
if container.hostConfig.NetworkMode.IsHost() {
@@ -910,7 +1004,8 @@ func (container *Container) initializeNetworking() error {
container.HostsPath = hostsPath
return ioutil.WriteFile(container.HostsPath, content, 0644)
} else if container.hostConfig.NetworkMode.IsContainer() {
}
if container.hostConfig.NetworkMode.IsContainer() {
// we need to get the hosts files from the container to join
nc, err := container.getNetworkedContainer()
if err != nil {
@@ -920,16 +1015,16 @@ func (container *Container) initializeNetworking() error {
container.ResolvConfPath = nc.ResolvConfPath
container.Config.Hostname = nc.Config.Hostname
container.Config.Domainname = nc.Config.Domainname
} else if container.daemon.config.DisableNetwork {
return nil
}
if container.daemon.config.DisableNetwork {
container.Config.NetworkDisabled = true
return container.buildHostnameAndHostsFiles("127.0.1.1")
} else {
if err := container.allocateNetwork(); err != nil {
return err
}
return container.buildHostnameAndHostsFiles(container.NetworkSettings.IPAddress)
}
return nil
if err := container.AllocateNetwork(); err != nil {
return err
}
return container.buildHostnameAndHostsFiles(container.NetworkSettings.IPAddress)
}
// Make sure the config is compatible with the current kernel
@@ -970,7 +1065,7 @@ func (container *Container) setupLinkedContainers() ([]string, error) {
}
for linkAlias, child := range children {
if !child.State.IsRunning() {
if !child.IsRunning() {
return nil, fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
}
@@ -1002,10 +1097,15 @@ func (container *Container) setupLinkedContainers() ([]string, error) {
}
func (container *Container) createDaemonEnvironment(linkedEnv []string) []string {
// if a domain name was specified, append it to the hostname (see #7851)
fullHostname := container.Config.Hostname
if container.Config.Domainname != "" {
fullHostname = fmt.Sprintf("%s.%s", fullHostname, container.Config.Domainname)
}
// Setup environment
env := []string{
"PATH=" + DefaultPathEnv,
"HOSTNAME=" + container.Config.Hostname,
"HOSTNAME=" + fullHostname,
// Note: we don't set HOME here because it'll get autoset intelligently
// based on the value of USER inside dockerinit, but only if it isn't
// set already (ie, that can be overridden by setting HOME via -e or ENV
@@ -1074,7 +1174,7 @@ func (container *Container) waitForStart() error {
// process or until the process is running in the container
select {
case <-container.monitor.startSignal:
case err := <-utils.Go(container.monitor.Start):
case err := <-promise.Go(container.monitor.Start):
return err
}
@@ -1101,7 +1201,6 @@ func (container *Container) allocatePort(eng *engine.Engine, port nat.Port, bind
return err
}
if err := job.Run(); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
b.HostIp = portEnv.Get("HostIP")
@@ -1137,7 +1236,7 @@ func (container *Container) getNetworkedContainer() (*Container, error) {
if nc == nil {
return nil, fmt.Errorf("no such container to join network: %s", parts[1])
}
if !nc.State.IsRunning() {
if !nc.IsRunning() {
return nil, fmt.Errorf("cannot join network of a non running container: %s", parts[1])
}
return nc, nil

View File

@@ -178,3 +178,20 @@ func TestGetFullName(t *testing.T) {
t.Fatal("Error should not be nil")
}
}
func TestValidContainerNames(t *testing.T) {
invalidNames := []string{"-rm", "&sdfsfd", "safd%sd"}
validNames := []string{"word-word", "word_word", "1weoid"}
for _, name := range invalidNames {
if validContainerNamePattern.MatchString(name) {
t.Fatalf("%q is not a valid container name and was returned as valid.", name)
}
}
for _, name := range validNames {
if !validContainerNamePattern.MatchString(name) {
t.Fatalf("%q is a valid container name and was returned as invalid.", name)
}
}
}

View File

@@ -15,8 +15,8 @@ func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status {
return job.Errorf("Usage: %s", job.Name)
}
config := runconfig.ContainerConfigFromJob(job)
if config.Memory != 0 && config.Memory < 524288 {
return job.Errorf("Minimum memory limit allowed is 512k")
if config.Memory != 0 && config.Memory < 4194304 {
return job.Errorf("Minimum memory limit allowed is 4MB")
}
if config.Memory > 0 && !daemon.SystemConfig().MemoryLimit {
job.Errorf("Your kernel does not support memory limit capabilities. Limitation discarded.\n")
@@ -26,7 +26,16 @@ func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status {
job.Errorf("Your kernel does not support swap limit capabilities. Limitation discarded.\n")
config.MemorySwap = -1
}
container, buildWarnings, err := daemon.Create(config, name)
var hostConfig *runconfig.HostConfig
if job.EnvExists("HostConfig") {
hostConfig = runconfig.ContainerHostConfigFromJob(job)
} else {
// Older versions of the API don't provide a HostConfig.
hostConfig = nil
}
container, buildWarnings, err := daemon.Create(config, hostConfig, name)
if err != nil {
if daemon.Graph().IsNotExist(err) {
_, tag := parsers.ParseRepositoryTag(config.Image)
@@ -50,11 +59,12 @@ func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status {
for _, warning := range buildWarnings {
job.Errorf("%s\n", warning)
}
return engine.StatusOK
}
// Create creates a new container from the given configuration with a given name.
func (daemon *Daemon) Create(config *runconfig.Config, name string) (*Container, []string, error) {
func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.HostConfig, name string) (*Container, []string, error) {
var (
container *Container
warnings []string
@@ -73,14 +83,19 @@ func (daemon *Daemon) Create(config *runconfig.Config, name string) (*Container,
if container, err = daemon.newContainer(name, config, img); err != nil {
return nil, nil, err
}
if err := daemon.Register(container); err != nil {
return nil, nil, err
}
if err := daemon.createRootfs(container, img); err != nil {
return nil, nil, err
}
if hostConfig != nil {
if err := daemon.setHostConfig(container, hostConfig); err != nil {
return nil, nil, err
}
}
if err := container.ToDisk(); err != nil {
return nil, nil, err
}
if err := daemon.Register(container); err != nil {
return nil, nil, err
}
return container, warnings, nil
}

View File

@@ -14,7 +14,6 @@ import (
"github.com/docker/libcontainer/label"
"github.com/docker/docker/archive"
"github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/daemon/execdriver/execdrivers"
"github.com/docker/docker/daemon/execdriver/lxc"
@@ -26,22 +25,25 @@ import (
"github.com/docker/docker/engine"
"github.com/docker/docker/graph"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/broadcastwriter"
"github.com/docker/docker/pkg/graphdb"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/namesgenerator"
"github.com/docker/docker/pkg/networkfs/resolvconf"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/pkg/truncindex"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/trust"
"github.com/docker/docker/utils"
"github.com/docker/docker/volumes"
)
var (
DefaultDns = []string{"8.8.8.8", "8.8.4.4"}
validContainerNameChars = `[a-zA-Z0-9_.-]`
validContainerNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
validContainerNamePattern = regexp.MustCompile(`^/?` + validContainerNameChars + `+$`)
)
@@ -84,33 +86,32 @@ type Daemon struct {
repository string
sysInitPath string
containers *contStore
execCommands *execStore
graph *graph.Graph
repositories *graph.TagStore
idIndex *truncindex.TruncIndex
sysInfo *sysinfo.SysInfo
volumes *graph.Graph
volumes *volumes.Repository
eng *engine.Engine
config *Config
containerGraph *graphdb.Database
driver graphdriver.Driver
execDriver execdriver.Driver
trustStore *trust.TrustStore
}
// Install installs daemon capabilities to eng.
func (daemon *Daemon) Install(eng *engine.Engine) error {
// FIXME: rename "delete" to "rm" for consistency with the CLI command
// FIXME: rename ContainerDestroy to ContainerRm for consistency with the CLI command
// FIXME: remove ImageDelete's dependency on Daemon, then move to graph/
for name, method := range map[string]engine.Handler{
"attach": daemon.ContainerAttach,
"build": daemon.CmdBuild,
"commit": daemon.ContainerCommit,
"container_changes": daemon.ContainerChanges,
"container_copy": daemon.ContainerCopy,
"container_inspect": daemon.ContainerInspect,
"containers": daemon.Containers,
"create": daemon.ContainerCreate,
"delete": daemon.ContainerDestroy,
"rm": daemon.ContainerRm,
"export": daemon.ContainerExport,
"info": daemon.CmdInfo,
"kill": daemon.ContainerKill,
@@ -124,6 +125,9 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
"unpause": daemon.ContainerUnpause,
"wait": daemon.ContainerWait,
"image_delete": daemon.ImageDelete, // FIXME: see above
"execCreate": daemon.ContainerExecCreate,
"execStart": daemon.ContainerExecStart,
"execResize": daemon.ContainerExecResize,
} {
if err := eng.Register(name, method); err != nil {
return err
@@ -132,6 +136,9 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
if err := daemon.Repositories().Install(eng); err != nil {
return err
}
if err := daemon.trustStore.Install(eng); err != nil {
return err
}
// FIXME: this hack is necessary for legacy integration tests to access
// the daemon object.
eng.Hack_SetGlobalVar("httpapi.daemon", daemon)
@@ -163,7 +170,11 @@ func (daemon *Daemon) containerRoot(id string) string {
// Load reads the contents of a container from disk
// This is typically done at startup.
func (daemon *Daemon) load(id string) (*Container, error) {
container := &Container{root: daemon.containerRoot(id), State: NewState()}
container := &Container{
root: daemon.containerRoot(id),
State: NewState(),
execCommands: newExecStore(),
}
if err := container.FromDisk(); err != nil {
return nil, err
}
@@ -204,7 +215,7 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
if container.Config.OpenStdin {
container.stdin, container.stdinPipe = io.Pipe()
} else {
container.stdinPipe = utils.NopWriteCloser(ioutil.Discard) // Silently drop stdin
container.stdinPipe = ioutils.NopWriteCloser(ioutil.Discard) // Silently drop stdin
}
// done
daemon.containers.Add(container.ID, container)
@@ -216,11 +227,11 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
// FIXME: if the container is supposed to be running but is not, auto restart it?
// if so, then we need to restart monitor and init a new lock
// If the container is supposed to be running, make sure of it
if container.State.IsRunning() {
if container.IsRunning() {
log.Debugf("killing old running container %s", container.ID)
existingPid := container.State.Pid
container.State.SetStopped(0)
existingPid := container.Pid
container.SetStopped(0)
// We only have to handle this for lxc because the other drivers will ensure that
// no processes are left when docker dies
@@ -232,7 +243,7 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
ID: container.ID,
}
var err error
cmd.Process, err = os.FindProcess(existingPid)
cmd.ProcessConfig.Process, err = os.FindProcess(existingPid)
if err != nil {
log.Debugf("cannot find existing process for %d", existingPid)
}
@@ -252,7 +263,7 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
log.Debugf("Marking as stopped")
container.State.SetStopped(-127)
container.SetStopped(-127)
if err := container.ToDisk(); err != nil {
return err
}
@@ -366,7 +377,7 @@ func (daemon *Daemon) restore() error {
for _, container := range registeredContainers {
if container.hostConfig.RestartPolicy.Name == "always" ||
(container.hostConfig.RestartPolicy.Name == "on-failure" && container.State.ExitCode != 0) {
(container.hostConfig.RestartPolicy.Name == "on-failure" && container.ExitCode != 0) {
log.Debugf("Starting container %s", container.ID)
if err := container.Start(); err != nil {
@@ -376,6 +387,10 @@ func (daemon *Daemon) restore() error {
}
}
for _, c := range registeredContainers {
c.registerVolumes()
}
if !debug {
log.Infof(": done.")
}
@@ -498,21 +513,46 @@ func (daemon *Daemon) generateHostname(id string, config *runconfig.Config) {
}
}
func (daemon *Daemon) getEntrypointAndArgs(config *runconfig.Config) (string, []string) {
func (daemon *Daemon) getEntrypointAndArgs(configEntrypoint, configCmd []string) (string, []string) {
var (
entrypoint string
args []string
)
if len(config.Entrypoint) != 0 {
entrypoint = config.Entrypoint[0]
args = append(config.Entrypoint[1:], config.Cmd...)
if len(configEntrypoint) != 0 {
entrypoint = configEntrypoint[0]
args = append(configEntrypoint[1:], configCmd...)
} else {
entrypoint = config.Cmd[0]
args = config.Cmd[1:]
entrypoint = configCmd[0]
args = configCmd[1:]
}
return entrypoint, args
}
func parseSecurityOpt(container *Container, config *runconfig.HostConfig) error {
var (
labelOpts []string
err error
)
for _, opt := range config.SecurityOpt {
con := strings.SplitN(opt, ":", 2)
if len(con) == 1 {
return fmt.Errorf("Invalid --security-opt: %q", opt)
}
switch con[0] {
case "label":
labelOpts = append(labelOpts, con[1])
case "apparmor":
container.AppArmorProfile = con[1]
default:
return fmt.Errorf("Invalid --security-opt: %q", opt)
}
}
container.ProcessLabel, container.MountLabel, err = label.InitLabels(labelOpts)
return err
}
func (daemon *Daemon) newContainer(name string, config *runconfig.Config, img *image.Image) (*Container, error) {
var (
id string
@@ -524,7 +564,7 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, img *i
}
daemon.generateHostname(id, config)
entrypoint, args := daemon.getEntrypointAndArgs(config)
entrypoint, args := daemon.getEntrypointAndArgs(config.Entrypoint, config.Cmd)
container := &Container{
// FIXME: we should generate the ID here instead of receiving it as an argument
@@ -540,13 +580,10 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, img *i
Driver: daemon.driver.String(),
ExecDriver: daemon.execDriver.Name(),
State: NewState(),
execCommands: newExecStore(),
}
container.root = daemon.containerRoot(container.ID)
if container.ProcessLabel, container.MountLabel, err = label.GenLabels(""); err != nil {
return nil, err
}
return container, nil
return container, err
}
func (daemon *Daemon) createRootfs(container *Container, img *image.Image) error {
@@ -623,6 +660,15 @@ func (daemon *Daemon) Children(name string) (map[string]*Container, error) {
return children, nil
}
func (daemon *Daemon) Parents(name string) ([]string, error) {
name, err := GetFullContainerName(name)
if err != nil {
return nil, err
}
return daemon.containerGraph.Parents(name)
}
func (daemon *Daemon) RegisterLink(parent, child *Container, alias string) error {
fullName := path.Join(parent.Name, alias)
if !daemon.containerGraph.Exists(fullName) {
@@ -683,8 +729,10 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
if !config.EnableIptables && !config.InterContainerCommunication {
return nil, fmt.Errorf("You specified --iptables=false with --icc=false. ICC uses iptables to function. Please set --icc or --iptables to true.")
}
// FIXME: DisableNetworkBidge doesn't need to be public anymore
config.DisableNetwork = config.BridgeIface == DisableNetworkBridge
if !config.EnableIptables && config.EnableIpMasq {
config.EnableIpMasq = false
}
config.DisableNetwork = config.BridgeIface == disableNetworkBridge
// Claim the pidfile first, to avoid any and all unexpected race conditions.
// Some of the init doesn't need a pidfile lock - but let's not try to be smart.
@@ -699,25 +747,24 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
}
// Check that the system is supported and we have sufficient privileges
// FIXME: return errors instead of calling Fatal
if runtime.GOOS != "linux" {
log.Fatalf("The Docker daemon is only supported on linux")
return nil, fmt.Errorf("The Docker daemon is only supported on linux")
}
if os.Geteuid() != 0 {
log.Fatalf("The Docker daemon needs to be run as root")
return nil, fmt.Errorf("The Docker daemon needs to be run as root")
}
if err := checkKernelAndArch(); err != nil {
log.Fatalf(err.Error())
return nil, err
}
// set up the TempDir to use a canonical path
tmp, err := utils.TempDir(config.Root)
if err != nil {
log.Fatalf("Unable to get the TempDir under %s: %s", config.Root, err)
return nil, fmt.Errorf("Unable to get the TempDir under %s: %s", config.Root, err)
}
realTmp, err := utils.ReadSymlinkedDirectory(tmp)
if err != nil {
log.Fatalf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
return nil, fmt.Errorf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
}
os.Setenv("TMPDIR", realTmp)
if !config.EnableSelinuxSupport {
@@ -731,7 +778,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
} else {
realRoot, err = utils.ReadSymlinkedDirectory(config.Root)
if err != nil {
log.Fatalf("Unable to get the full path to root (%s): %s", config.Root, err)
return nil, fmt.Errorf("Unable to get the full path to root (%s): %s", config.Root, err)
}
}
config.Root = realRoot
@@ -751,7 +798,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
log.Debugf("Using graph driver %s", driver)
// As Docker on btrfs and SELinux are incompatible at present, error on both being enabled
if config.EnableSelinuxSupport && driver.String() == "btrfs" {
if selinuxEnabled() && config.EnableSelinuxSupport && driver.String() == "btrfs" {
return nil, fmt.Errorf("SELinux is not supported with the BTRFS graph driver!")
}
@@ -772,31 +819,41 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
return nil, err
}
// We don't want to use a complex driver like aufs or devmapper
// for volumes, just a plain filesystem
volumesDriver, err := graphdriver.GetDriver("vfs", config.Root, config.GraphOptions)
if err != nil {
return nil, err
}
log.Debugf("Creating volumes graph")
volumes, err := graph.NewGraph(path.Join(config.Root, "volumes"), volumesDriver)
volumes, err := volumes.NewRepository(path.Join(config.Root, "volumes"), volumesDriver)
if err != nil {
return nil, err
}
log.Debugf("Creating repository list")
repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g)
repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g, config.Mirrors, config.InsecureRegistries)
if err != nil {
return nil, fmt.Errorf("Couldn't create Tag store: %s", err)
}
trustDir := path.Join(config.Root, "trust")
if err := os.MkdirAll(trustDir, 0700); err != nil && !os.IsExist(err) {
return nil, err
}
t, err := trust.NewTrustStore(trustDir)
if err != nil {
return nil, fmt.Errorf("could not create trust store: %s", err)
}
if !config.DisableNetwork {
job := eng.Job("init_networkdriver")
job.SetenvBool("EnableIptables", config.EnableIptables)
job.SetenvBool("InterContainerCommunication", config.InterContainerCommunication)
job.SetenvBool("EnableIpForward", config.EnableIpForward)
job.SetenvBool("EnableIpMasq", config.EnableIpMasq)
job.Setenv("BridgeIface", config.BridgeIface)
job.Setenv("BridgeIP", config.BridgeIP)
job.Setenv("FixedCIDR", config.FixedCIDR)
job.Setenv("DefaultBindingIP", config.DefaultIp.String())
if err := job.Run(); err != nil {
@@ -839,6 +896,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
daemon := &Daemon{
repository: daemonRepo,
containers: &contStore{s: make(map[string]*Container)},
execCommands: newExecStore(),
graph: g,
repositories: repositories,
idIndex: truncindex.NewTruncIndex([]string{}),
@@ -850,9 +908,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
sysInitPath: sysInitPath,
execDriver: ed,
eng: eng,
}
if err := daemon.checkLocaldns(); err != nil {
return nil, err
trustStore: t,
}
if err := daemon.restore(); err != nil {
return nil, err
@@ -885,7 +941,7 @@ func (daemon *Daemon) shutdown() error {
log.Debugf("starting clean shutdown of all containers...")
for _, container := range daemon.List() {
c := container
if c.State.IsRunning() {
if c.IsRunning() {
log.Debugf("stopping %s", c.ID)
group.Add(1)
@@ -894,7 +950,7 @@ func (daemon *Daemon) shutdown() error {
if err := c.KillSig(15); err != nil {
log.Debugf("kill 15 error for %s - %s", c.ID, err)
}
c.State.WaitStop(-1 * time.Second)
c.WaitStop(-1 * time.Second)
log.Debugf("container stopped %s", c.ID)
}()
}
@@ -924,46 +980,13 @@ func (daemon *Daemon) Unmount(container *Container) error {
}
func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) {
if differ, ok := daemon.driver.(graphdriver.Differ); ok {
return differ.Changes(container.ID)
}
cDir, err := daemon.driver.Get(container.ID, "")
if err != nil {
return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.daemon.driver, err)
}
defer daemon.driver.Put(container.ID)
initDir, err := daemon.driver.Get(container.ID+"-init", "")
if err != nil {
return nil, fmt.Errorf("Error getting container init rootfs %s from driver %s: %s", container.ID, container.daemon.driver, err)
}
defer daemon.driver.Put(container.ID + "-init")
return archive.ChangesDirs(cDir, initDir)
initID := fmt.Sprintf("%s-init", container.ID)
return daemon.driver.Changes(container.ID, initID)
}
func (daemon *Daemon) Diff(container *Container) (archive.Archive, error) {
if differ, ok := daemon.driver.(graphdriver.Differ); ok {
return differ.Diff(container.ID)
}
changes, err := daemon.Changes(container)
if err != nil {
return nil, err
}
cDir, err := daemon.driver.Get(container.ID, "")
if err != nil {
return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.daemon.driver, err)
}
archive, err := archive.ExportChanges(cDir, changes)
if err != nil {
return nil, err
}
return utils.NewReadCloserWrapper(archive, func() error {
err := archive.Close()
daemon.driver.Put(container.ID)
return err
}), nil
initID := fmt.Sprintf("%s-init", container.ID)
return daemon.driver.Diff(container.ID, initID)
}
func (daemon *Daemon) Run(c *Container, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
@@ -974,7 +997,7 @@ func (daemon *Daemon) Pause(c *Container) error {
if err := daemon.execDriver.Pause(c.command); err != nil {
return err
}
c.State.SetPaused()
c.SetPaused()
return nil
}
@@ -982,7 +1005,7 @@ func (daemon *Daemon) Unpause(c *Container) error {
if err := daemon.execDriver.Unpause(c.command); err != nil {
return err
}
c.State.SetUnpaused()
c.SetUnpaused()
return nil
}
@@ -1042,26 +1065,10 @@ func (daemon *Daemon) ExecutionDriver() execdriver.Driver {
return daemon.execDriver
}
func (daemon *Daemon) Volumes() *graph.Graph {
return daemon.volumes
}
func (daemon *Daemon) ContainerGraph() *graphdb.Database {
return daemon.containerGraph
}
func (daemon *Daemon) checkLocaldns() error {
resolvConf, err := resolvconf.Get()
if err != nil {
return err
}
if len(daemon.config.Dns) == 0 && utils.CheckLocalDns(resolvConf) {
log.Infof("Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : %v", DefaultDns)
daemon.config.Dns = DefaultDns
}
return nil
}
func (daemon *Daemon) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {
// Retrieve all images
images, err := daemon.Graph().Map()

View File

@@ -0,0 +1,39 @@
package daemon
import (
"testing"
"github.com/docker/docker/runconfig"
)
func TestParseSecurityOpt(t *testing.T) {
container := &Container{}
config := &runconfig.HostConfig{}
// test apparmor
config.SecurityOpt = []string{"apparmor:test_profile"}
if err := parseSecurityOpt(container, config); err != nil {
t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
}
if container.AppArmorProfile != "test_profile" {
t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", container.AppArmorProfile)
}
// test valid label
config.SecurityOpt = []string{"label:user:USER"}
if err := parseSecurityOpt(container, config); err != nil {
t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
}
// test invalid label
config.SecurityOpt = []string{"label"}
if err := parseSecurityOpt(container, config); err == nil {
t.Fatal("Expected parseSecurityOpt error, got nil")
}
// test invalid opt
config.SecurityOpt = []string{"test"}
if err := parseSecurityOpt(container, config); err == nil {
t.Fatal("Expected parseSecurityOpt error, got nil")
}
}

View File

@@ -4,15 +4,12 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/log"
)
// FIXME: rename to ContainerRemove for consistency with the CLI command.
func (daemon *Daemon) ContainerDestroy(job *engine.Job) engine.Status {
func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status {
if len(job.Args) != 1 {
return job.Errorf("Not enough arguments. Usage: %s CONTAINER\n", job.Name)
}
@@ -22,10 +19,11 @@ func (daemon *Daemon) ContainerDestroy(job *engine.Job) engine.Status {
forceRemove := job.GetenvBool("forceRemove")
container := daemon.Get(name)
if container == nil {
return job.Errorf("No such container: %s", name)
}
if removeLink {
if container == nil {
return job.Errorf("No such link: %s", name)
}
name, err := GetFullContainerName(name)
if err != nil {
job.Error(err)
@@ -51,7 +49,7 @@ func (daemon *Daemon) ContainerDestroy(job *engine.Job) engine.Status {
}
if container != nil {
if container.State.IsRunning() {
if container.IsRunning() {
if forceRemove {
if err := container.Kill(); err != nil {
return job.Errorf("Could not kill running container, cannot remove - %v", err)
@@ -64,73 +62,22 @@ func (daemon *Daemon) ContainerDestroy(job *engine.Job) engine.Status {
return job.Errorf("Cannot destroy container %s: %s", name, err)
}
container.LogEvent("destroy")
if removeVolume {
var (
volumes = make(map[string]struct{})
binds = make(map[string]struct{})
usedVolumes = make(map[string]*Container)
)
// the volume id is always the base of the path
getVolumeId := func(p string) string {
return filepath.Base(strings.TrimSuffix(p, "/layer"))
}
// populate bind map so that they can be skipped and not removed
for _, bind := range container.HostConfig().Binds {
source := strings.Split(bind, ":")[0]
// TODO: refactor all volume stuff, all of it
// it is very important that we eval the link or comparing the keys to container.Volumes will not work
//
// eval symlink can fail, ref #5244 if we receive an is not exist error we can ignore it
p, err := filepath.EvalSymlinks(source)
if err != nil && !os.IsNotExist(err) {
return job.Error(err)
}
if p != "" {
source = p
}
binds[source] = struct{}{}
}
// Store all the deleted containers volumes
for _, volumeId := range container.Volumes {
// Skip the volumes mounted from external
// bind mounts here will will be evaluated for a symlink
if _, exists := binds[volumeId]; exists {
continue
}
volumeId = getVolumeId(volumeId)
volumes[volumeId] = struct{}{}
}
// Retrieve all volumes from all remaining containers
for _, container := range daemon.List() {
for _, containerVolumeId := range container.Volumes {
containerVolumeId = getVolumeId(containerVolumeId)
usedVolumes[containerVolumeId] = container
}
}
for volumeId := range volumes {
// If the requested volu
if c, exists := usedVolumes[volumeId]; exists {
log.Infof("The volume %s is used by the container %s. Impossible to remove it. Skipping.", volumeId, c.ID)
continue
}
if err := daemon.Volumes().Delete(volumeId); err != nil {
return job.Errorf("Error calling volumes.Delete(%q): %v", volumeId, err)
}
}
daemon.DeleteVolumes(container.VolumePaths())
}
} else {
return job.Errorf("No such container: %s", name)
}
return engine.StatusOK
}
func (daemon *Daemon) DeleteVolumes(volumeIDs map[string]struct{}) {
for id := range volumeIDs {
if err := daemon.volumes.Delete(id); err != nil {
log.Infof("%s", err)
continue
}
}
}
// Destroy unregisters a container from the daemon and cleanly removes its contents from the filesystem.
// FIXME: rename to Rm for consistency with the CLI command
func (daemon *Daemon) Destroy(container *Container) error {
@@ -150,7 +97,7 @@ func (daemon *Daemon) Destroy(container *Container) error {
// Deregister the container before removing its directory, to avoid race conditions
daemon.idIndex.Delete(container.ID)
daemon.containers.Delete(container.ID)
container.derefVolumes()
if _, err := daemon.containerGraph.Purge(container.ID); err != nil {
log.Debugf("Unable to remove container from link graph: %s", err)
}
@@ -168,6 +115,10 @@ func (daemon *Daemon) Destroy(container *Container) error {
return fmt.Errorf("Unable to remove filesystem for %v: %v", container.ID, err)
}
if err := daemon.execDriver.Clean(container.ID); err != nil {
return fmt.Errorf("Unable to remove execdriver data for %s: %s", container.ID, err)
}
selinuxFreeLxcContexts(container.ProcessLabel)
return nil

301
daemon/exec.go Normal file
View File

@@ -0,0 +1,301 @@
// build linux
package daemon
import (
"fmt"
"io"
"io/ioutil"
"strings"
"sync"
"github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/daemon/execdriver/lxc"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/broadcastwriter"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/utils"
)
type execConfig struct {
sync.Mutex
ID string
Running bool
ProcessConfig execdriver.ProcessConfig
StreamConfig
OpenStdin bool
OpenStderr bool
OpenStdout bool
Container *Container
}
type execStore struct {
s map[string]*execConfig
sync.Mutex
}
func newExecStore() *execStore {
return &execStore{s: make(map[string]*execConfig, 0)}
}
func (e *execStore) Add(id string, execConfig *execConfig) {
e.Lock()
e.s[id] = execConfig
e.Unlock()
}
func (e *execStore) Get(id string) *execConfig {
e.Lock()
res := e.s[id]
e.Unlock()
return res
}
func (e *execStore) Delete(id string) {
e.Lock()
delete(e.s, id)
e.Unlock()
}
func (execConfig *execConfig) Resize(h, w int) error {
return execConfig.ProcessConfig.Terminal.Resize(h, w)
}
func (d *Daemon) registerExecCommand(execConfig *execConfig) {
// Storing execs in container inorder to kill them gracefully whenever the container is stopped or removed.
execConfig.Container.execCommands.Add(execConfig.ID, execConfig)
// Storing execs in daemon for easy access via remote API.
d.execCommands.Add(execConfig.ID, execConfig)
}
func (d *Daemon) getExecConfig(name string) (*execConfig, error) {
if execConfig := d.execCommands.Get(name); execConfig != nil {
if !execConfig.Container.IsRunning() {
return nil, fmt.Errorf("Container %s is not running", execConfig.Container.ID)
}
return execConfig, nil
}
return nil, fmt.Errorf("No such exec instance '%s' found in daemon", name)
}
func (d *Daemon) unregisterExecCommand(execConfig *execConfig) {
execConfig.Container.execCommands.Delete(execConfig.ID)
d.execCommands.Delete(execConfig.ID)
}
func (d *Daemon) getActiveContainer(name string) (*Container, error) {
container := d.Get(name)
if container == nil {
return nil, fmt.Errorf("No such container: %s", name)
}
if !container.IsRunning() {
return nil, fmt.Errorf("Container %s is not running", name)
}
return container, nil
}
func (d *Daemon) ContainerExecCreate(job *engine.Job) engine.Status {
if len(job.Args) != 1 {
return job.Errorf("Usage: %s [options] container command [args]", job.Name)
}
if strings.HasPrefix(d.execDriver.Name(), lxc.DriverName) {
return job.Error(lxc.ErrExec)
}
var name = job.Args[0]
container, err := d.getActiveContainer(name)
if err != nil {
return job.Error(err)
}
config := runconfig.ExecConfigFromJob(job)
entrypoint, args := d.getEntrypointAndArgs(nil, config.Cmd)
processConfig := execdriver.ProcessConfig{
Privileged: config.Privileged,
User: config.User,
Tty: config.Tty,
Entrypoint: entrypoint,
Arguments: args,
}
execConfig := &execConfig{
ID: utils.GenerateRandomID(),
OpenStdin: config.AttachStdin,
OpenStdout: config.AttachStdout,
OpenStderr: config.AttachStderr,
StreamConfig: StreamConfig{},
ProcessConfig: processConfig,
Container: container,
Running: false,
}
d.registerExecCommand(execConfig)
job.Printf("%s\n", execConfig.ID)
return engine.StatusOK
}
func (d *Daemon) ContainerExecStart(job *engine.Job) engine.Status {
if len(job.Args) != 1 {
return job.Errorf("Usage: %s [options] exec", job.Name)
}
var (
cStdin io.ReadCloser
cStdout, cStderr io.Writer
cStdinCloser io.Closer
execName = job.Args[0]
)
execConfig, err := d.getExecConfig(execName)
if err != nil {
return job.Error(err)
}
func() {
execConfig.Lock()
defer execConfig.Unlock()
if execConfig.Running {
err = fmt.Errorf("Error: Exec command %s is already running", execName)
}
execConfig.Running = true
}()
if err != nil {
return job.Error(err)
}
log.Debugf("starting exec command %s in container %s", execConfig.ID, execConfig.Container.ID)
container := execConfig.Container
if execConfig.OpenStdin {
r, w := io.Pipe()
go func() {
defer w.Close()
io.Copy(w, job.Stdin)
}()
cStdin = r
cStdinCloser = job.Stdin
}
if execConfig.OpenStdout {
cStdout = job.Stdout
}
if execConfig.OpenStderr {
cStderr = job.Stderr
}
execConfig.StreamConfig.stderr = broadcastwriter.New()
execConfig.StreamConfig.stdout = broadcastwriter.New()
// Attach to stdin
if execConfig.OpenStdin {
execConfig.StreamConfig.stdin, execConfig.StreamConfig.stdinPipe = io.Pipe()
} else {
execConfig.StreamConfig.stdinPipe = ioutils.NopWriteCloser(ioutil.Discard) // Silently drop stdin
}
attachErr := d.Attach(&execConfig.StreamConfig, execConfig.OpenStdin, false, execConfig.ProcessConfig.Tty, cStdin, cStdinCloser, cStdout, cStderr)
execErr := make(chan error)
// Remove exec from daemon and container.
defer d.unregisterExecCommand(execConfig)
go func() {
err := container.Exec(execConfig)
if err != nil {
execErr <- fmt.Errorf("Cannot run exec command %s in container %s: %s", execName, container.ID, err)
}
}()
select {
case err := <-attachErr:
if err != nil {
return job.Errorf("attach failed with error: %s", err)
}
break
case err := <-execErr:
return job.Error(err)
}
return engine.StatusOK
}
func (d *Daemon) Exec(c *Container, execConfig *execConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
return d.execDriver.Exec(c.command, &execConfig.ProcessConfig, pipes, startCallback)
}
func (container *Container) Exec(execConfig *execConfig) error {
container.Lock()
defer container.Unlock()
waitStart := make(chan struct{})
callback := func(processConfig *execdriver.ProcessConfig, pid int) {
if processConfig.Tty {
// The callback is called after the process Start()
// so we are in the parent process. In TTY mode, stdin/out/err is the PtySlave
// which we close here.
if c, ok := processConfig.Stdout.(io.Closer); ok {
c.Close()
}
}
close(waitStart)
}
// We use a callback here instead of a goroutine and an chan for
// syncronization purposes
cErr := promise.Go(func() error { return container.monitorExec(execConfig, callback) })
// Exec should not return until the process is actually running
select {
case <-waitStart:
case err := <-cErr:
return err
}
return nil
}
func (container *Container) monitorExec(execConfig *execConfig, callback execdriver.StartCallback) error {
var (
err error
exitCode int
)
pipes := execdriver.NewPipes(execConfig.StreamConfig.stdin, execConfig.StreamConfig.stdout, execConfig.StreamConfig.stderr, execConfig.OpenStdin)
exitCode, err = container.daemon.Exec(container, execConfig, pipes, callback)
if err != nil {
log.Errorf("Error running command in existing container %s: %s", container.ID, err)
}
log.Debugf("Exec task in container %s exited with code %d", container.ID, exitCode)
if execConfig.OpenStdin {
if err := execConfig.StreamConfig.stdin.Close(); err != nil {
log.Errorf("Error closing stdin while running in %s: %s", container.ID, err)
}
}
if err := execConfig.StreamConfig.stdout.Clean(); err != nil {
log.Errorf("Error closing stdout while running in %s: %s", container.ID, err)
}
if err := execConfig.StreamConfig.stderr.Clean(); err != nil {
log.Errorf("Error closing stderr while running in %s: %s", container.ID, err)
}
if execConfig.ProcessConfig.Terminal != nil {
if err := execConfig.ProcessConfig.Terminal.Close(); err != nil {
log.Errorf("Error closing terminal while running in container %s: %s", container.ID, err)
}
}
return err
}

View File

@@ -20,7 +20,7 @@ var (
ErrDriverNotFound = errors.New("The requested docker init has not been found")
)
type StartCallback func(*Command)
type StartCallback func(*ProcessConfig, int)
// Driver specific information based on
// processes registered with the driver
@@ -42,6 +42,8 @@ type TtyTerminal interface {
type Driver interface {
Run(c *Command, pipes *Pipes, startCallback StartCallback) (int, error) // Run executes the process and blocks until the process exits and returns the exit code
// Exec executes the process in an existing container, blocks until the process exits and returns the exit code
Exec(c *Command, processConfig *ProcessConfig, pipes *Pipes, startCallback StartCallback) (int, error)
Kill(c *Command, sig int) error
Pause(c *Command) error
Unpause(c *Command) error
@@ -49,6 +51,7 @@ type Driver interface {
Info(id string) Info // "temporary" hack (until we move state from core to plugins)
GetPidsForContainer(id string) ([]int, error) // Returns a list of pids for the given container.
Terminate(c *Command) error // kill it with fire
Clean(id string) error // clean all traces of container exec
}
// Network settings of the container
@@ -62,8 +65,9 @@ type Network struct {
type NetworkInterface struct {
Gateway string `json:"gateway"`
IPAddress string `json:"ip"`
Bridge string `json:"bridge"`
IPPrefixLen int `json:"ip_prefix_len"`
MacAddress string `json:"mac_address"`
Bridge string `json:"bridge"`
}
type Resources struct {
@@ -78,38 +82,40 @@ type Mount struct {
Destination string `json:"destination"`
Writable bool `json:"writable"`
Private bool `json:"private"`
Slave bool `json:"slave"`
}
// Describes a process that will be run inside a container.
type ProcessConfig struct {
exec.Cmd `json:"-"`
Privileged bool `json:"privileged"`
User string `json:"user"`
Tty bool `json:"tty"`
Entrypoint string `json:"entrypoint"`
Arguments []string `json:"arguments"`
Terminal Terminal `json:"-"` // standard or tty terminal
Console string `json:"-"` // dev/console path
}
// Process wrapps an os/exec.Cmd to add more metadata
type Command struct {
exec.Cmd `json:"-"`
ID string `json:"id"`
Privileged bool `json:"privileged"`
User string `json:"user"`
Rootfs string `json:"rootfs"` // root fs of the container
InitPath string `json:"initpath"` // dockerinit
Entrypoint string `json:"entrypoint"`
Arguments []string `json:"arguments"`
WorkingDir string `json:"working_dir"`
ConfigPath string `json:"config_path"` // this should be able to be removed when the lxc template is moved into the driver
Tty bool `json:"tty"`
Network *Network `json:"network"`
Config map[string][]string `json:"config"` // generic values that specific drivers can consume
Resources *Resources `json:"resources"`
Mounts []Mount `json:"mounts"`
AllowedDevices []*devices.Device `json:"allowed_devices"`
AutoCreatedDevices []*devices.Device `json:"autocreated_devices"`
CapAdd []string `json:"cap_add"`
CapDrop []string `json:"cap_drop"`
Terminal Terminal `json:"-"` // standard or tty terminal
Console string `json:"-"` // dev/console path
ContainerPid int `json:"container_pid"` // the pid for the process inside a container
}
// Return the pid of the process
// If the process is nil -1 will be returned
func (c *Command) Pid() int {
return c.ContainerPid
ID string `json:"id"`
Rootfs string `json:"rootfs"` // root fs of the container
InitPath string `json:"initpath"` // dockerinit
WorkingDir string `json:"working_dir"`
ConfigPath string `json:"config_path"` // this should be able to be removed when the lxc template is moved into the driver
Network *Network `json:"network"`
Resources *Resources `json:"resources"`
Mounts []Mount `json:"mounts"`
AllowedDevices []*devices.Device `json:"allowed_devices"`
AutoCreatedDevices []*devices.Device `json:"autocreated_devices"`
CapAdd []string `json:"cap_add"`
CapDrop []string `json:"cap_drop"`
ContainerPid int `json:"container_pid"` // the pid for the process inside a container
ProcessConfig ProcessConfig `json:"process_config"` // Describes the init process of the container.
ProcessLabel string `json:"process_label"`
MountLabel string `json:"mount_label"`
LxcConfig []string `json:"lxc_config"`
AppArmorProfile string `json:"apparmor_profile"`
}

View File

@@ -2,6 +2,7 @@ package lxc
import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
@@ -21,12 +22,13 @@ import (
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/utils"
"github.com/docker/libcontainer/cgroups"
"github.com/docker/libcontainer/label"
"github.com/docker/libcontainer/mount/nodes"
)
const DriverName = "lxc"
var ErrExec = errors.New("Unsupported: Exec is not supported by the lxc driver")
type driver struct {
root string // root path for the driver to use
initPath string
@@ -59,12 +61,12 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
err error
)
if c.Tty {
term, err = NewTtyConsole(c, pipes)
if c.ProcessConfig.Tty {
term, err = NewTtyConsole(&c.ProcessConfig, pipes)
} else {
term, err = execdriver.NewStdConsole(c, pipes)
term, err = execdriver.NewStdConsole(&c.ProcessConfig, pipes)
}
c.Terminal = term
c.ProcessConfig.Terminal = term
c.Mounts = append(c.Mounts, execdriver.Mount{
Source: d.initPath,
@@ -98,11 +100,11 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
"-mtu", strconv.Itoa(c.Network.Mtu),
)
if c.User != "" {
params = append(params, "-u", c.User)
if c.ProcessConfig.User != "" {
params = append(params, "-u", c.ProcessConfig.User)
}
if c.Privileged {
if c.ProcessConfig.Privileged {
if d.apparmor {
params[0] = path.Join(d.root, "lxc-start-unconfined")
@@ -122,8 +124,8 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
params = append(params, fmt.Sprintf("-cap-drop=%s", strings.Join(c.CapDrop, ":")))
}
params = append(params, "--", c.Entrypoint)
params = append(params, c.Arguments...)
params = append(params, "--", c.ProcessConfig.Entrypoint)
params = append(params, c.ProcessConfig.Arguments...)
if d.sharedRoot {
// lxc-start really needs / to be non-shared, or all kinds of stuff break
@@ -149,14 +151,14 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
if err != nil {
aname = name
}
c.Path = aname
c.Args = append([]string{name}, arg...)
c.ProcessConfig.Path = aname
c.ProcessConfig.Args = append([]string{name}, arg...)
if err := nodes.CreateDeviceNodes(c.Rootfs, c.AutoCreatedDevices); err != nil {
return -1, err
}
if err := c.Start(); err != nil {
if err := c.ProcessConfig.Start(); err != nil {
return -1, err
}
@@ -166,7 +168,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
)
go func() {
if err := c.Wait(); err != nil {
if err := c.ProcessConfig.Wait(); err != nil {
if _, ok := err.(*exec.ExitError); !ok { // Do not propagate the error if it's simply a status code != 0
waitErr = err
}
@@ -177,9 +179,9 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
// Poll lxc for RUNNING status
pid, err := d.waitForStart(c, waitLock)
if err != nil {
if c.Process != nil {
c.Process.Kill()
c.Wait()
if c.ProcessConfig.Process != nil {
c.ProcessConfig.Process.Kill()
c.ProcessConfig.Wait()
}
return -1, err
}
@@ -187,7 +189,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
c.ContainerPid = pid
if startCallback != nil {
startCallback(c)
startCallback(&c.ProcessConfig, pid)
}
<-waitLock
@@ -198,10 +200,10 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
/// Return the exit code of the process
// if the process has not exited -1 will be returned
func getExitCode(c *execdriver.Command) int {
if c.ProcessState == nil {
if c.ProcessConfig.ProcessState == nil {
return -1
}
return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
return c.ProcessConfig.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
}
func (d *driver) Kill(c *execdriver.Command, sig int) error {
@@ -407,42 +409,29 @@ func rootIsShared() bool {
}
func (d *driver) generateLXCConfig(c *execdriver.Command) (string, error) {
var (
process, mount string
root = path.Join(d.root, "containers", c.ID, "config.lxc")
labels = c.Config["label"]
)
root := path.Join(d.root, "containers", c.ID, "config.lxc")
fo, err := os.Create(root)
if err != nil {
return "", err
}
defer fo.Close()
if len(labels) > 0 {
process, mount, err = label.GenLabels(labels[0])
if err != nil {
return "", err
}
}
if err := LxcTemplateCompiled.Execute(fo, struct {
*execdriver.Command
AppArmor bool
ProcessLabel string
MountLabel string
AppArmor bool
}{
Command: c,
AppArmor: d.apparmor,
ProcessLabel: process,
MountLabel: mount,
Command: c,
AppArmor: d.apparmor,
}); err != nil {
return "", err
}
return root, nil
}
func (d *driver) generateEnvConfig(c *execdriver.Command) error {
data, err := json.Marshal(c.Env)
data, err := json.Marshal(c.ProcessConfig.Env)
if err != nil {
return err
}
@@ -457,12 +446,17 @@ func (d *driver) generateEnvConfig(c *execdriver.Command) error {
return ioutil.WriteFile(p, data, 0600)
}
// Clean not implemented for lxc
func (d *driver) Clean(id string) error {
return nil
}
type TtyConsole struct {
MasterPty *os.File
SlavePty *os.File
}
func NewTtyConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*TtyConsole, error) {
func NewTtyConsole(processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes) (*TtyConsole, error) {
// lxc is special in that we cannot create the master outside of the container without
// opening the slave because we have nothing to provide to the cmd. We have to open both then do
// the crazy setup on command right now instead of passing the console path to lxc and telling it
@@ -478,12 +472,12 @@ func NewTtyConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*TtyCo
SlavePty: ptySlave,
}
if err := tty.AttachPipes(&command.Cmd, pipes); err != nil {
if err := tty.AttachPipes(&processConfig.Cmd, pipes); err != nil {
tty.Close()
return nil, err
}
command.Console = tty.SlavePty.Name()
processConfig.Console = tty.SlavePty.Name()
return tty, nil
}
@@ -527,3 +521,7 @@ func (t *TtyConsole) Close() error {
t.SlavePty.Close()
return t.MasterPty.Close()
}
func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
return -1, ErrExec
}

View File

@@ -13,7 +13,7 @@ import (
"strings"
"syscall"
"github.com/docker/docker/reexec"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/libcontainer/netlink"
)

Some files were not shown because too many files have changed in this diff Show More