Commit graph

8160 commits

Author SHA1 Message Date
Victor Vieux
68fb7f4b74 Standardize API keys: CamelCase
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-31 01:22:07 +00:00
unclejack
0ef637722f Merge pull request #6097 from timthelion/consistentdevices
Refactor device handling code
2014-05-31 03:34:52 +03:00
unclejack
b46449cb33 Merge pull request #6123 from vieux/no_number_default
no default default number in names
2014-05-31 00:55:11 +03:00
unclejack
c90faa47b6 Merge pull request #6065 from vieux/fix_race_waitlock
update container's state after we close the waitLock
2014-05-31 00:38:35 +03:00
Timothy Hobbs
608702b980 Refactor device handling code
We now have one place that keeps track of (most) devices that are allowed and created within the container.  That place is pkg/libcontainer/devices/devices.go

This fixes several inconsistencies between which devices were created in the lxc backend and the native backend.  It also fixes inconsistencies between wich devices were created and which were allowed.  For example, /dev/full was being created but it was not allowed within the cgroup.  It also declares the file modes and permissions of the default devices, rather than copying them from the host.  This is in line with docker's philosphy of not being host dependent.

Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)
2014-05-30 19:21:29 +00:00
Victor Vieux
e70a5ab014 no default default number in names
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-30 19:08:21 +00:00
unclejack
0fd0deb75d optimize restore & use Getenv less in daemon.go
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-05-30 21:20:27 +03:00
Alexandr Morozov
af17b01ad7 Goroutine-safe daemon.containers
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-30 16:08:06 +04:00
Alexandr Morozov
64bd6a6a53 Fix race in native driver on activeContainers usage
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-30 14:16:00 +04:00
Alexandr Morozov
4e5f6951f2 Fix races in set/get currentInterfaces in networkdriver
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-30 14:16:00 +04:00
unclejack
e8a87120d4 block aufs on incompatible file systems
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-05-30 02:32:27 +03:00
Johannes 'fish' Ziemke
75754e69f6 Add ErrPrerequisites to improve misleading errors
There are two cases where we can't use a graphdriver:

1) the graphdriver itself isn't supported by the system
2) the graphdriver is supported by some configuration/prerequisites are
missing

This introduces a new error for the 2) case and uses it when trying to
run docker with btrfs backend on a non-btrfs filesystem.

Docker-DCO-1.1-Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org> (github: discordianfish)
2014-05-29 17:09:55 +02:00
Victor Marmol
5e2af07137 Merge pull request #5868 from jhspaybar/5749-libcontainerroutes
libcontainer support for arbitrary route table entries
2014-05-28 10:50:56 -07:00
William Thurston
bf7f360dca Fixes #5749
libcontainer support for arbitrary route table entries

Docker-DCO-1.1-Signed-off-by: William Thurston <me@williamthurston.com> (github: jhspaybar)
2014-05-28 17:42:02 +00:00
Michael Crosby
6964012382 Return devmapper errors with additional text
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-27 19:03:57 -07:00
Victor Vieux
1de52caedc update container's state after we close the waitLock
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-28 00:18:51 +00:00
Michael Crosby
5310e8575f Update lxc to use cmd.Wait()
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-27 13:52:05 -07:00
Dinesh Subhraveti
249524ec49 Add Dinesh Subhraveti to MAINTAINERS
Docker-DCO-1.1-Signed-off-by: Dinesh Subhraveti <dineshs@altiscale.com> (github: dineshs-altiscale)
2014-05-27 16:45:17 -04:00
Victor Vieux
a605379927 Merge pull request #6059 from erikh/fix-tests
Fix race condition in CLI tests: diff was not acquiring a container lock
2014-05-27 13:19:32 -07:00
unclejack
0d9a5ce6dd Merge pull request #6025 from crosbymichael/concurrent-names
Improve name generation on concurrent requests
2014-05-27 23:18:19 +03:00
Erik Hollensbe
8b77e0183e Fix race condition in CLI tests: diff was not acquiring a container lock
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-05-27 12:28:31 -07:00
Erik Hollensbe
92e41a02ce Add Wait() calls in the appropriate spots
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-05-27 12:26:56 -07:00
Michael Crosby
bdb5aa4c27 Merge pull request #5937 from LK4D4/ipallocator_refactoring
Ip allocator refactoring
2014-05-27 12:22:36 -07:00
Victor Vieux
754797bba7 Merge pull request #6000 from cyphar/5619-fix-unsafe-path-resolution
Properly handle paths with symlink path components
2014-05-27 12:06:19 -07:00
Alexandr Morozov
ef94ac7d2f Ip allocator refactoring
We don't need ordered set anymore, also some cleanings and simple
benchmark.
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-27 22:56:26 +04:00
cyphar
328d2cba11 daemon: container: properly handle paths with symlink path components
This patch fixes the incorrect handling of paths which contain a
symlink as a path component when copying data from a container.
Essentially, this patch changes the container.Copy() method to
first "resolve" the resource by resolving all of symlinks encountered
in the path relative to the container's rootfs (using pkg/symlink).

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-05-24 11:01:19 +10:00
Michael Crosby
6ec86cb6e5 Improve name generation on concurrent requests
Fixes #2586

This fixes a few races where the name generator asks if a name is free
but another container takes the name before it can be reserved.  This
solves this by generating the name and setting it.  If the set fails
with a non unique error then we try again.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-23 17:51:16 -07:00
Dan Walsh
a3ff8a98f7 We need to umount /var/lib/docker when the daemon exits.
Currently we are leaving it bind mounted on stop.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-05-23 11:43:46 -04:00
Victor Vieux
0abb52c7a9 add recursive device nodes
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-22 22:29:13 +00:00
Alexander Larsson
42708181b1 devmapper: Don't enable discard during mkfs.ext4
There is no reason to do discard durink mkfs, as the filesystem
is on a newly allocated device anyway. Discard is a slow operation,
so this may help initial startup a bit, especially if you use a larger
thin pool.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-22 09:23:52 +02:00
Victor Vieux
55d41c3e21 Merge pull request #5976 from crosbymichael/getpids
Move get pid into cgroup implementation
2014-05-21 19:09:50 -07:00
Victor Vieux
5a0a03e394 Merge pull request #5922 from crosbymichael/host-dev-priv
Mount /dev in tmpfs for privileged containers
2014-05-21 18:56:24 -07:00
Michael Crosby
4bb4bf634a Merge pull request #5859 from philips/append-etc-hosts-not-bind
fix(daemon): prepend host /etc/hosts instead of bind mounting
2014-05-21 15:57:59 -07:00
Michael Crosby
811d93326b Move get pid into cgroup implementation
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-21 21:14:07 +00:00
Victor Vieux
b7f9e683c3 Merge pull request #5958 from erikh/5738-docker_port_in_use
docker port in use
2014-05-21 21:06:27 +00:00
Victor Vieux
457cb86cf2 Merge pull request #5975 from tianon/revert-run-tmpfs
Revert "Always mount a /run tmpfs in the container"
2014-05-21 13:46:48 -07:00
Tianon Gravi
8e967fe802 Revert "Always mount a /run tmpfs in the container"
This reverts commit 905795ece6.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
2014-05-21 14:28:19 -06:00
Erik Hollensbe
91ba337931 bridge: retry any proxy set up failures until we get a successful port, defeats a race condition
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-05-21 09:14:53 -07:00
Erik Hollensbe
f0489ce3a9 portallocator: rewrite to simplify, removes race condition
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-05-21 09:14:53 -07:00
AnandkumarPatel
789a8f2616 use buffered channel so goroutine does not get blocked on done <- true when a timeout occurs.
Docker-DCO-1.1-Signed-off-by: Anandkumar Patel <anandkumarpatel@gmail.com> (github: anandkumarpatel)
2014-05-20 21:33:40 -07:00
Michael Crosby
f042c3c157 Update code post codereview
Add specific types for Required and Optional DeviceNodes
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-21 00:40:41 +00:00
Michael Crosby
34c05c58c8 Mount /dev in tmpfs for privileged containers
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-20 22:51:24 +00:00
Michael Crosby
83e9dc7200 Merge pull request #5755 from vieux/move_inspect_daemon
move inspect from server to daemon
2014-05-20 15:50:38 -07:00
Michael Crosby
1310243d48 Merge pull request #5946 from crosbymichael/lxc-host-net
Fix network mode for lxc 1.0
2014-05-20 14:51:33 -07:00
Michael Crosby
70d35b9d39 Merge pull request #5918 from crosbymichael/volumes-commit
Do not commit host bind mounts into image
2014-05-20 14:28:49 -07:00
Victor Vieux
603e00a3a7 move inspect from server to daemon
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-20 19:36:15 +00:00
Michael Crosby
0f27894094 Fix network mode for lxc 1.0
Fixes #5692

This change requires lxc 1.0+ to work and breaks lxc versions less than
1.0 for host networking.  We think that this is a find tradeoff by
bumping docker to only support lxc 1.0
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-20 19:10:23 +00:00
Alexander Larsson
fcf2e9a910 native driver: Add required capabilities
We need SETFCAP to be able to mark files as having caps, which is
heavily used by fedora.
See https://github.com/dotcloud/docker/issues/5928

We also need SETPCAP, for instance systemd needs this to set caps
on its childen.

Both of these are safe in the sense that they can never ever
result in a process with a capability not in the bounding set of the
container.

We also add NET_BIND_SERVICE caps, to be able to bind to ports lower
than 1024.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-20 11:31:39 +02:00
Brandon Philips
000a37fe9d fix(daemon): prepend host /etc/hosts instead of bind mounting
systemd systems do not require a /etc/hosts file exists since an nss
module is shipped that creates localhost implicitly. So, mounting
/etc/hosts can fail on these sorts of systems, as was reported on CoreOS
in issue #5812.

Instead of trying to bind mount just copy the hosts entries onto the
containers private /etc/hosts.

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
2014-05-19 22:32:51 -07:00
Michael Crosby
d535d98100 Don't save bind mounts in image
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-19 22:18:37 +00:00
Michael Crosby
e454be7567 Move init volumes code to func
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-19 22:04:51 +00:00
Victor Vieux
c12dd77090 starts by removing the name from the graph db
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-19 21:22:33 +00:00
Victor Vieux
40c8fc668c Merge pull request #5876 from timthelion/docs-daemon-readme
Add readme for daemon directory
2014-05-19 10:51:17 -07:00
Victor Marmol
0abad3ae22 Don't drop CAP_FOWNER in the container. Also sorts the list of allowed
capabilities.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-05-19 16:52:39 +00:00
Timothy
b175b4dd43 Add readme for daemon directory
See issue #5873

Docker-DCO-1.1-Signed-off-by: Timothy <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)
2014-05-17 17:56:02 +00:00
Victor Marmol
92614928ce Make libcontainer's CapabilitiesMask into a []string (Capabilities).
Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-05-17 00:44:10 +00:00
Victor Marmol
01d10d6f13 Merge pull request #5810 from vmarmol/drop-caps
Change libcontainer to drop all capabilities by default.
2014-05-16 11:51:41 -07:00
Michael Crosby
dbd6f10b3d Merge pull request #5842 from alexlarsson/dm-cleanup-tests
devicemapper: Remove non-general tests
2014-05-16 11:08:04 -07:00
Alexander Larsson
39d244a593 devmapper: Remove sys.go mocking framework
This is no longer needed, as the tests are gone.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-16 14:12:56 +02:00
Timothy Hobbs
408f050d64 Typo in execdrivers.go five => give
Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: timthelion)
2014-05-16 11:45:20 +00:00
Alexander Larsson
bd6fd25dfb devicemapper: Remove non-general tests
Now that we have the generic graphtest tests that actually tests
the driver we can remove the old mock-using tests. Almost all of
these tests were disabled anyway, and the four remaining ones
didn't really test much while at the same time being really
fragile and making the rest of the code more complex due to
the mocking setup.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-16 12:46:28 +02:00
Victor Marmol
9d6875d19d Change libcontainer to drop all capabilities by default. Only keeps
those that were specified in the config. This commit also explicitly
adds a set of capabilities that we were silently not dropping and were
assumed by the tests.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-05-16 00:57:58 +00:00
Michael Crosby
08a7bcf5db Merge pull request #5497 from alexlarsson/generic-driver-tests
graphdriver: Add generic test framework for graph drivers
2014-05-15 17:21:09 -07:00
Michael Crosby
3b7a19def6 Move cgroups package into libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-14 15:21:44 -07:00
Guillaume J. Charmes
17a1f470ae Merge pull request #5783 from LK4D4/fix_duplicate_ip_allocation_#5729
Fix duplicate ip allocation
2014-05-14 13:32:27 -07:00
Michael Crosby
4af465fccf Merge pull request #5720 from cyphar/5656-cp-absolute-paths
Ensure `docker cp` cannot traverse outside container rootfs
2014-05-14 11:46:11 -07:00
Victor Vieux
d066ceaa4f Merge pull request #5752 from crosbymichael/fix-port-mapping-ps
Fix port mapping in ps display for public and private
2014-05-14 11:36:23 -07:00
Victor Vieux
bc22c9948c Merge pull request #5756 from crosbymichael/move-units-to-pkg
Move duration and size to units pkg
2014-05-14 11:36:14 -07:00
Michael Crosby
de406b69f3 Merge pull request #5798 from unclejack/fix_startup_speed
don't update Suffixarray for every Register during startup
2014-05-14 11:13:02 -07:00
unclejack
fc82199d4f Merge pull request #5758 from crosbymichael/add-cpuset
Add cpuset cpus support for docker
2014-05-14 20:57:12 +03:00
unclejack
5d5c89398c update Suffixarray only once during daemon startup
This commit makes the Docker daemon call UpdateSuffixarray only after
it finishes registering all containers.

This lowers the amount of time required for the Docker daemon to start
up.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-05-14 17:58:37 +03:00
unclejack
e963179c79 don't call sort for every add in history
This moves the call to sort in daemon/history to a function to be
called explicitly when we're done adding elements to the list.

This speeds up `docker ps`.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-05-14 15:02:02 +03:00
Alexandr Morozov
80fca061e7 Change ip allocation logic
Now IP reuses only after all IPs from network was allocated
Fixes #5729

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-14 06:43:10 +04:00
Michael Crosby
adbe3096e8 Add cpuset cpus support for docker
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-13 18:17:12 -07:00
cyphar
0fb507dc23 daemon: *: refactored container resource path generation
This patch is a preventative patch, it fixes possible future
vulnerabilities regarding unsantised paths. Due to several recent
vulnerabilities, wherein the docker daemon could be fooled into
accessing data from the host (rather than a container), this patch
was created to try and mitigate future possible vulnerabilities in
the same vein.

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-05-14 11:15:50 +10:00
cyphar
bfc3a4192a daemon: container: ensure cp cannot traverse outside container rootfs
This patch fixes the bug that allowed cp to copy files outside of
the containers rootfs, by passing a relative path (such as
../../../../../../../../etc/shadow). This is fixed by first converting
the path to an absolute path (relative to /) and then appending it
to the container's rootfs before continuing.

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-05-14 11:14:59 +10:00
Michael Crosby
ca040b1a37 Update code to handle new path to Follow Symlink func
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-13 10:54:08 -07:00
unclejack
f1eabe436a Merge pull request #5655 from alexlarsson/mount-run-dir
Always mount a /run tmpfs in the container
2014-05-13 11:51:14 +03:00
Victor Vieux
100a92146e move RegisterLinks to daemon
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-13 00:54:46 +00:00
Michael Crosby
d33b4655c4 Move duration and size to units pkg
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-12 17:05:07 -07:00
Michael Crosby
d54dec4d8b Fix port mapping in ps display for public and private
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-12 15:26:23 -07:00
Guillaume J. Charmes
bc77ec2b17 Merge pull request #5717 from philips/mkdir-in-daemon
fix(daemon): ensure the /var/lib/docker dir exists
2014-05-12 14:13:56 -07:00
Alexander Larsson
905795ece6 Always mount a /run tmpfs in the container
All modern distros set up /run to be a tmpfs, see for instance:
https://wiki.debian.org/ReleaseGoals/RunDirectory

Its a very useful place to store pid-files, sockets and other things
that only live at runtime and that should not be stored in the image.

This is also useful when running systemd inside a container, as it
will try to mount /run if not already mounted, which will fail for
non-privileged container.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-12 21:41:04 +02:00
Michael Crosby
243eaac8b6 Merge pull request #5724 from tutumcloud/5718-lxcbugfix
Fix bug on LXC container start. Fixes #5718
2014-05-12 12:14:57 -07:00
Fernando
752c57ae56 Fix bug on LXC container start. Fixes #5718
Docker-DCO-1.1-Signed-off-by: Fernando Mayo <fernando@tutum.co> (github: fermayo)
2014-05-10 18:05:02 -04:00
Brandon Philips
b4ccd7cbfb fix(daemon): ensure the /var/lib/docker dir exists
The btrfs driver attempts to stat the /var/lib/docker directory to
ensure it exists. If it doesn't exist then it bails with an unhelpful
log line:

```
2014/05/10 00:51:30 no such file or directory
```

In 0.10 the directory was created but quickly digging through the logs I
can't tell what sort of re-ordering of code caused this regression.

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
2014-05-09 18:09:26 -07:00
Alexander Larsson
55cd7dd7f9 grapdriver: Skip tests on non-supported backends
For now this means the btrfs backend is skipped when run
inside make test. You can however run it manually if you want.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-09 14:48:39 +02:00
Alexander Larsson
4bdb8c03fc graphdriver: Fail initialization if supported but got error
If a graphdriver fails initialization due to ErrNotSupported we ignore
that and keep trying the next. But if some driver has a different
error (for instance if you specified an unknown option for it) we fail
the daemon startup, printing the error, rather than falling back to an
unexected driver (typically vfs) which may not match what you have run
earlier.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-09 14:48:39 +02:00
Alexander Larsson
27744062aa graphdriver: Add generic test framework for graph drivers
This adds daemon/graphdriver/graphtest/graphtest which has a few
generic tests for all graph drivers, and then uses these
from the btrs, devicemapper and vfs backends.

I've not yet added the aufs backend, because i can't test that here
atm. It should work though.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-09 14:48:39 +02:00
Alexander Larsson
84f19a09ac vfs graphdriver: Make root dir mode 755
This matches the other backends.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-09 14:48:38 +02:00
Alexander Larsson
47c79870ea devmapper: Properly restore mocked functions after test
Currently the tests that mocks or denies functions leave this state
around for the next test. This is no good if we want to actually
test the devicemapper code in later tests.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-09 14:48:38 +02:00
Alexander Larsson
bff0c4f3dc devmapper: Remove accidental debug spew
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-08 19:25:47 +02:00
Alexander Larsson
3a1703a79f Merge pull request #5404 from alexlarsson/dm-new-metadata
Make devicemapper backend able to support multiple processes
2014-05-08 14:31:17 +02:00
Michael Crosby
62e8ddb579 Set container pid for process in native driver
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-06 17:04:04 -07:00
Bryan Murphy
53f38a14cd add linked containers to hosts file
Docker-DCO-1.1-Signed-off-by: Bryan Murphy <bmurphy1976@gmail.com> (github: bmurphy1976)

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
Tested-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-05-05 19:40:27 -07:00
Michael Crosby
cd81895091 Add alex as devmapper and btrfs maintainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 19:40:27 -07:00
Michael Crosby
41cfaa738c Move Attach from container to daemon
This moves the Attach method from the container to the daemon.  This
method mostly supports the http attach logic and does not have anything
to do with the running of a container.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 16:48:56 -07:00
Victor Vieux
b4ac4228f5 Merge pull request #5613 from vieux/better_error_handling
propagate errors write
2014-05-05 16:28:15 -07:00
Victor Vieux
55f3e72d7f propagate errors write
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-05 23:23:14 +00:00
Guillaume J. Charmes
0b15944cb0 Merge pull request #5354 from alexlarsson/cgroups-systemd-fixes
cgroups: Update systemd to match fs backend
2014-05-05 16:00:56 -07:00
Victor Vieux
0736eb6d16 Merge pull request #5609 from crosbymichael/move-env-gen 2014-05-05 15:52:47 -07:00
Victor Vieux
3744452ecf add resolvconf
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-05 22:55:32 +00:00
Victor Vieux
a1a029f6d7 add etchosts
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-05-05 22:43:38 +00:00
Michael Crosby
4994b0fe54 Move envconfig generation to lxc driver
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 14:45:14 -07:00
Michael Crosby
01fec73ba4 Update after namespace refactor
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 13:56:18 -07:00
Guillaume J. Charmes
70fef1460a Merge pull request #4441 from crosbymichael/add-net-flag
Add --net flag to docker run and allow host network stack
2014-05-05 13:54:55 -07:00
Michael Crosby
db5f6b4aa0 Improve libcontainer namespace and cap format
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 12:34:21 -07:00
Alexander Larsson
5b094530c0 cgroups: Update systemd to match fs backend
This updates systemd.Apply to match the fs backend by:
* Always join blockio controller (for stats)
* Support CpusetCpus
* Support MemorySwap

Also, it removes the generic UnitProperties in favour of a single
option to set the slice.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-05 20:06:44 +02:00
Michael Crosby
0b187b909b Address code review feedback
Also make sure we copy the joining containers hosts and resolv.conf with
the hostname if we are joining it's network stack.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 10:08:59 -07:00
Michael Crosby
5ca6532011 Update host networking with hostname and files
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 10:08:59 -07:00
Michael Crosby
a785882b29 Setup host networking for lxc and native
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 10:08:59 -07:00
Michael Crosby
2c2cc051d8 Update --net flags and container mode
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-05 10:08:59 -07:00
Johan Euphrosine
a60159f3b1 runconfig: add -net container:name option
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
2014-05-05 10:08:59 -07:00
Michael Crosby
3a1f0dedc7 Merge pull request #5556 from crosbymichael/no-restrict-lxc
Don't restrict lxc because of apparmor
2014-05-02 17:20:27 -07:00
Guillaume J. Charmes
103d028132 Merge pull request #5560 from gabrtv/deregister-containers-earlier
De-register containers before removing driver and containerGraph references
2014-05-02 15:20:51 -07:00
Guillaume J. Charmes
8913ec4912
Remove unused daemon/sorter.go
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
2014-05-02 14:16:05 -07:00
Gabriel Monroy
9f152aacf8 deregister containers before removing driver and containerGraph references
This is required to address a race condition described in #5553,
where a container can be partially deleted -- for example, the
root filesystem but not the init filesystem -- which makes
it impossible to delete the container without re-adding the
missing filesystems manually.

This behavior has been witnessed when rebooting boxes that
are configured to remove containers on shutdown in parallel
with stopping the Docker daemon.

Docker-DCO-1.1-Signed-off-by: Gabriel Monroy <gabriel@opdemand.com> (github: gabrtv)
2014-05-02 13:27:17 -06:00
Michael Crosby
59fe77bfa6 Don't restrict lxc because of apparmor
We don't have the flexibility to do extra things with lxc because it is
a black box and most fo the magic happens before we get a chance to
interact with it in dockerinit.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-02 11:14:24 -07:00
Michael Crosby
f5139233b9 Update restrictions for better handling of mounts
This also cleans up some of the left over restriction paths code from
before.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-01 15:26:58 -07:00
Jérôme Petazzoni
1c4202a614 Mount /proc and /sys read-only, except in privileged containers.
It has been pointed out that some files in /proc and /sys can be used
to break out of containers. However, if those filesystems are mounted
read-only, most of the known exploits are mitigated, since they rely
on writing some file in those filesystems.

This does not replace security modules (like SELinux or AppArmor), it
is just another layer of security. Likewise, it doesn't mean that the
other mitigations (shadowing parts of /proc or /sys with bind mounts)
are useless. Those measures are still useful. As such, the shadowing
of /proc/kcore is still enabled with both LXC and native drivers.

Special care has to be taken with /proc/1/attr, which still needs to
be mounted read-write in order to enable the AppArmor profile. It is
bind-mounted from a private read-write mount of procfs.

All that enforcement is done in dockerinit. The code doing the real
work is in libcontainer. The init function for the LXC driver calls
the function from libcontainer to avoid code duplication.

Docker-DCO-1.1-Signed-off-by: Jérôme Petazzoni <jerome@docker.com> (github: jpetazzo)
2014-05-01 15:26:58 -07:00
Michael Crosby
20bcb80f40 Merge pull request #5457 from tiborvass/5423-bridge-ip
Fix bridge ip comparison
2014-05-01 11:56:47 -07:00
Eiichi Tsukata
cac0cea03f drop CAP_SYSLOG capability
Kernel capabilities for privileged syslog operations are currently splitted into
CAP_SYS_ADMIN and CAP_SYSLOG since the following commit:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ce6ada35bdf710d16582cc4869c26722547e6f11

This patch drops CAP_SYSLOG to prevent containers from messing with
host's syslog (e.g. `dmesg -c` clears up host's printk ring buffer).

Closes #5491

Docker-DCO-1.1-Signed-off-by: Eiichi Tsukata <devel@etsukata.com> (github: Etsukata)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-01 11:43:55 -07:00
Guillaume J. Charmes
fe4a25546a Merge pull request #5515 from crosbymichael/refactor-libcontainer2
Remove CommandFactory and NsInit interface
2014-05-01 11:41:54 -07:00
Alexandr Morozov
d1297feef8 Timestamps for docker logs.
Fixes #1165
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-01 20:40:36 +04:00
Michael Crosby
da0d6dbd7b Make native driver use Exec func with different CreateCommand
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-30 18:49:24 -07:00
Michael Crosby
60e4276f5a Integrate new structure into docker's native driver
This duplicates some of the Exec code but I think it it worth it because
the native driver is more straight forward and does not have the
complexity have handling the type issues for now.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-30 18:20:01 -07:00
Michael Crosby
f110401437 Remove statewriter interface, export more libcontainer funcs
This temp. expands the Exec method's signature but adds a more robust
way to know when the container's process is actually released and begins
to run.  The network interfaces are not guaranteed to be up yet but this
provides a more accurate view with a single callback at this time.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-30 15:52:40 -07:00
Michael Crosby
162dafbcd5 Remove logger from nsinit struct
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-30 15:24:18 -07:00
Guillaume J. Charmes
2a711d16e0 Merge pull request #5448 from crosbymichael/selinux-defaults
Add selinux label support for processes and mount
2014-04-30 14:14:39 -07:00
Tibor Vass
986c647d5a Fix bridge ip comparison
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-04-30 12:36:16 -07:00
Michael Crosby
e88ef454b7 Merge pull request #5464 from tianon/close-leftover-fds 2014-04-30 12:27:52 -07:00
Tianon Gravi
d5d62ff955 Close extraneous file descriptors in containers
Without this patch, containers inherit the open file descriptors of the daemon, so my "exec 42>&2" allows us to "echo >&42 some nasty error with some bad advice" directly into the daemon log. :)

Also, "hack/dind" was already doing this due to issues caused by the inheritance, so I'm removing that hack too since this patch obsoletes it by generalizing it for all containers.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
2014-04-29 16:45:28 -06:00
Michael Crosby
1a5ffef6c6 Do not return labels when in privileged mode
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-29 03:40:06 -07:00
Michael Crosby
46e05ed2d9 Update process labels to be set at create not start
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-29 03:40:05 -07:00
Michael Crosby
ae00649305 Update devicemapper to pass mount flag
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-29 03:40:05 -07:00
Dan Walsh
b7942ec2ca This patch reworks the SELinux patch to be only run on demand by the daemon
Added --selinux-enable switch to daemon to enable SELinux labeling.

The daemon will now generate a new unique random SELinux label when a
container starts, and remove it when the container is removed.   The MCS
labels will be stored in the daemon memory.  The labels of containers will
be stored in the container.json file.

When the daemon restarts on boot or if done by an admin, it will read all containers json files and reserve the MCS labels.

A potential problem would be conflicts if you setup thousands of containers,
current scheme would handle ~500,000 containers.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: crosbymichael)
2014-04-29 03:40:05 -07:00
Michael Crosby
f0e6e135a8 Initial work on selinux patch
This has every container using the docker daemon's pid for the processes
label so it does not work correctly.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-29 03:40:05 -07:00
Michael Crosby
934bd15565 Merge pull request #5389 from tiborvass/5152-symlink-in-volume
Fixes #5152 : symlink in volume path
2014-04-28 17:27:18 -07:00
Brian Goff
ff7b52abd3 Fixes permissions on volumes when dir in container is empty
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-04-28 16:57:28 -04:00
Tibor Vass
e9a42a45bf Fixes #5152 : symlink in volume path
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-04-28 13:18:12 -07:00
unclejack
44140f7909 Merge pull request #5411 from crosbymichael/lockdown
Update default restrictions for exec drivers
2014-04-26 03:27:56 +03:00
unclejack
077b7d0359 Merge pull request #5342 from danielnorberg/avoid-suicide
avoid suicide
2014-04-25 21:44:45 +03:00
Alexander Larsson
6d631968fa devmapper: Store metadata in one file per device
This allows multiple instances of the backend in different containers
to access devices (although generally only one can modify/create them).

Any old metadata is converted on the first run.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-25 15:21:56 +02:00
Alexander Larsson
f26203cf54 devmapper: Simplify thin pool device id allocation
Instead of globally keeping track of the free device ids we just
start from 0 each run and handle EEXIST error and try the next one.

This way we don't need any global state for the device ids, which
means we can read device metadata lazily. This is important for
multi-process use of the backend.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-25 14:26:27 +02:00
Alexander Larsson
586a511cb5 devmapper: Move error detection to devmapper.go
This moves the EBUSY detection to devmapper.go, and then returns
a real ErrBusy that deviceset uses.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-25 14:26:27 +02:00
Alexander Larsson
8116b86e05 devmapper: Maks createSnapDevice a function, not a method
No idea why this was a method. Maybe a cut and paste bug.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-25 14:26:27 +02:00
Guillaume J. Charmes
85540f6aa0 Merge pull request #5373 from vmarmol/master
Separating cgroup Memory and MemoryReservation.
2014-04-24 14:28:40 -07:00
Michael Crosby
8af84c5e23 Merge pull request #5335 from alexlarsson/remove-ghost
container: Remove Ghost state
2014-04-24 11:55:05 -07:00
Victor Marmol
f188b9f623 Separating cgroup Memory and MemoryReservation.
This will allow for these to be set independently. Keep the current Docker behavior where Memory and MemoryReservation are set to the value of Memory.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-04-24 11:09:38 -07:00
Michael Crosby
2d6c367434 Increment native driver version with these changes
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-24 10:35:20 -07:00
Michael Crosby
5ba1242bdc Mount over dev and only copy allowed nodes in
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-24 10:35:20 -07:00
Michael Crosby
81e5026a6a No not mount sysfs by default for non privilged containers
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-24 10:35:20 -07:00
Michael Crosby
0779a8c328 Add lxc support for restricting proc
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-24 10:35:20 -07:00
Michael Crosby
60a90970bc Add restrictions to proc in libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-24 10:35:19 -07:00
Daniel Norberg
b3ddc31b95 avoid suicide
container.Kill() might read a pid of 0 from
container.State.Pid due to losing a race with
container.monitor() calling
container.State.SetStopped(). Sending a SIGKILL to
pid 0 is undesirable as "If pid equals 0, then sig
is sent to every process in the process group of
the calling process."

Docker-DCO-1.1-Signed-off-by: Daniel Norberg <daniel.norberg@gmail.com> (github: danielnorberg)
2014-04-23 11:06:59 -04:00
Alexander Larsson
73d9ede12c devicemapper: Don't mount in Create()
We used to mount in Create() to be able to create a few files that
needs to be in each device. However, this mount is problematic for
selinux, as we need to set the mount label at mount-time, and it
is not known at the time of Create().

This change just moves the file creation to first Get() call and
drops the mount from Create(). Additionally, this lets us remove
some complexities we had to avoid an extra unmount+mount cycle.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-23 13:50:53 +02:00
Alexander Larsson
cf997aa905 container: Remove Ghost state
container.Register() checks both IsRunning() and IsGhost(), but at
this point IsGhost() is always true if IsRunning() is true. For a
newly created container both are false, and for a restored-from-disk
container Daemon.load() sets Ghost to true if IsRunning is true. So we
just drop the IsGhost check.

This was the last call to IsGhost, so we remove It and all other
traces of the ghost state.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-22 09:49:53 +02:00
Guillaume J. Charmes
813cebc64f
Merge branch 'master' into load-profile
Conflicts:
	daemon/execdriver/native/create.go
	daemon/execdriver/native/driver.go

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
2014-04-21 10:32:13 -07:00
Michael Crosby
eceeebc22d Remove IsGhost checks around networking
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-04-17 23:49:59 +00:00
Alexander Larsson
359b7df5d2 Rename runtime/* to daemon/*
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-17 14:43:01 -07:00