Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overlayfs graph backend #7619

Merged
merged 1 commit into from Nov 14, 2014
Merged

Add overlayfs graph backend #7619

merged 1 commit into from Nov 14, 2014

Conversation

alexlarsson
Copy link
Contributor

This backend uses the overlayfs union filesystem for containers
plus hard link file sharing for images.

Each container/image can have a "root" subdirectory which is a plain
filesystem hierarchy, or they can use overlayfs.

If they use overlayfs there is a "upper" directory and a "lower-id"
file, as well as "merged" and "word" directories. The "upper"
directory has the upper layer of the overlay, and "lower-id" contains
the id of the parent whose "root" directory shall be used as the lower
layer in the overlay. The overlay itself is mounted in the "merged"
directory, and the "work" dir is needed for overlayfs to work.

When a overlay layer is created there are two cases, either the
parent has a "root" dir, then we start out with a empty "upper"
directory overlaid on the parents root. This is typically the
case with the init layer of a container which is based on an image.
If there is no "root" in the parent, we inherit the lower-id from
the parent and start by making a copy if the parents "upper" dir.
This is typically the case for a container layer which copies
its parent -init upper layer.

Additionally we also have a custom implementation of ApplyLayer
which makes a recursive copy of the parent "root" layer using
hardlinks to share file data, and then applies the layer on top
of that. This means all chile images share file (but not directory)
data with the parent.

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

@alexlarsson
Copy link
Contributor Author

Note: This targets v23 of overlayfs and was tested with the kernel from:
http://copr-fe.cloud.fedoraproject.org/coprs/jwboyer/kernel-playground/

Also, i noticed some kernel issues with removing directories from the lower layer in overlayfs when run on an btrfs filesystem, but it works fine when the backing filesystem is ext4.

@xiaods
Copy link
Contributor

xiaods commented Aug 20, 2014

Cool!

@renato-zannon
Copy link
Contributor

FYI, overlayfs has been merged, and will be on Linux 3.18 mainline

@xiaods
Copy link
Contributor

xiaods commented Oct 27, 2014

@alexlarsson we need rebase!

This backend uses the overlayfs union filesystem for containers
plus hard link file sharing for images.

Each container/image can have a "root" subdirectory which is a plain
filesystem hierarchy, or they can use overlayfs.

If they use overlayfs there is a "upper" directory and a "lower-id"
file, as well as "merged" and "work" directories. The "upper"
directory has the upper layer of the overlay, and "lower-id" contains
the id of the parent whose "root" directory shall be used as the lower
layer in the overlay. The overlay itself is mounted in the "merged"
directory, and the "work" dir is needed for overlayfs to work.

When a overlay layer is created there are two cases, either the
parent has a "root" dir, then we start out with a empty "upper"
directory overlaid on the parents root. This is typically the
case with the init layer of a container which is based on an image.
If there is no "root" in the parent, we inherit the lower-id from
the parent and start by making a copy if the parents "upper" dir.
This is typically the case for a container layer which copies
its parent -init upper layer.

Additionally we also have a custom implementation of ApplyLayer
which makes a recursive copy of the parent "root" layer using
hardlinks to share file data, and then applies the layer on top
of that. This means all chile images share file (but not directory)
data with the parent.

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

Rebased to master. I'm also looking at making it work with selinux. Researching the posibilities atm.

@crosbymichael
Copy link
Contributor

@alexlarsson thanks for the rebase. What are the existing tasks that still need to happen for this PR to be merged? Is there something that you need from us to help?

@alexlarsson
Copy link
Contributor Author

@crosbymichael It works as-is, but not with selinux. I'm trying to figure out a way to make it support selinux, and the solution may involve shuffling around the directories a bit in the backend directory, so maybe we should wait a bit before merging.

@alexlarsson
Copy link
Contributor Author

Also, there are some issues with overlayfs on top of other filesystems than ext4, the other filesystems need whiteout support similar to: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs?id=cd808deced431b66b5fa4e5c193cb7ec0059eaff

I'm hopeful this will happen for the common filesystems before 3.18 release though.

@philips
Copy link
Contributor

philips commented Oct 29, 2014

The approach and general naming of things lgtm!

@crosbymichael
Copy link
Contributor

Assigned @unclejack to see this one through. Looks awesome!

@jessfraz
Copy link
Contributor

@unclejack lmk if you want me to try it out, i was going to build the RC kernel anyways

@unclejack
Copy link
Contributor

I've tested this graph driver backend. This overlayfs backend seems to be working just fine.

LGTM

@jessfraz
Copy link
Contributor

I tested as well and it's pretty swell LGTM

@LK4D4
Copy link
Contributor

LK4D4 commented Nov 14, 2014

@unclejack @jfrazelle did you tested over btrfs?

@jessfraz
Copy link
Contributor

yes, tested over btrfs

@LK4D4
Copy link
Contributor

LK4D4 commented Nov 14, 2014

@jfrazelle ok, then I'll try too :D

@jessfraz
Copy link
Contributor

\o/

On Thu, Nov 13, 2014 at 8:56 PM, Alexandr Morozov notifications@github.com
wrote:

@jfrazelle https://github.com/jfrazelle ok, then I'll try too :D


Reply to this email directly or view it on GitHub
#7619 (comment).

@alexlarsson
Copy link
Contributor Author

I believe btrfs doesn't yet implement RENAME_WHITEOUT, so it will fail in some situations.

@cpuguy83
Copy link
Member

Also tested, but on ext4. Looks great!

@crosbymichael
Copy link
Contributor

I'm not worried about issues if you run this on top of btrfs. I wouldn't expect it to magically work as we all know, overlay filesystems on top of overlay filesystems or the like usually end in flames.

if strings.Contains(s.Text(), "overlayfs") {
return nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps a log.Debugf("overlayfs not found") or similar, otherwise there is no distinction of error from overlayfs support even being compiled into docker itself

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vbatts Do you think we need to change this before merging this graph driver? We could send a PR afterwards to make this change unless we decide this has to be changed before the merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vbatts
Copy link
Contributor

vbatts commented Nov 14, 2014

besides a non-blocking nit, LGTM
super excited to see this available.

@unclejack
Copy link
Contributor

Ok, I'll merge this PR. We can address @vbatts' comment in a PR.

Thanks, @alexlarsson!

unclejack added a commit that referenced this pull request Nov 14, 2014
@jeremyeder
Copy link

Yes! Congrats @alexlarsson :-)

@crosbymichael
Copy link
Contributor

just a FYI

i see this in the containers mount table using this driver:

overlayfs on / type overlayfs (rw,relatime,lowerdir=/var/lib/docker/overlayfs/e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287/root,upperdir=/var/lib/docker/overlayfs/cf59b21af2e83de2836ff04fb4581723e01e37de967bf54b75ceeaccf89e8b22/upper,workdir=/var/lib/docker/overlayfs/cf59b21af2e83de2836ff04fb4581723e01e37de967bf54b75ceeaccf89e8b22/work)

@thaJeztah
Copy link
Member

Nice!

Does this need a mention in the documentation (as "experimental")?

@helenxu1221
Copy link

I tried this overlayfs driver on Ubuntu 14.04.1 with ext4 file system as the root of the Docker runtime. I got this error "Error response from daemon: invalid argument". if I upgrade kernel to 3.18 rc3, then it works fine. Is overlayfs kernel support required? Thanks

@vbatts
Copy link
Contributor

vbatts commented Nov 18, 2014

@helenxu1221 correct. overlayfs is added in linux-3.18, which is not even released yet. The error of docker-supported-ness will get clearer soon. Thanks for testing.

@cpuguy83
Copy link
Member

@helenxu1221
Copy link

With overlayfs, is there a way to set container disk limit like dm.basesize option? Thanks

@unclejack
Copy link
Contributor

@helenxu1221 No, there's no such setting because this is similar to aufs.

@helenxu1221
Copy link

so there is no way to limit the container size? even from cgroup level.

@unclejack
Copy link
Contributor

No, there isn't.

vbatts added a commit to vbatts/moby that referenced this pull request Nov 19, 2014
based on moby#7619 (comment)

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
@alexlarsson
Copy link
Contributor Author

This needs to be updated since the fs name changed from overlayfs to overlay upstream:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ef94b1864d1ed5be54376404bb23d22ed0481feb

@cpuguy83
Copy link
Member

cpuguy83 commented Dec 1, 2014

See #9426 and #9405

mapuri pushed a commit to mapuri/docker that referenced this pull request Dec 4, 2014
based on moby#7619 (comment)

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
@marcellodesales
Copy link

Will this allow multiple Dockerfiles to be merged together?

@cpuguy83
Copy link
Member

@marcellodesales This is support for the Overlay filesystem
Which is an alternative to AUFS.

Not really anything to do with Dockerfiles or any change in how Docker itself works.

@marcellodesales
Copy link

@cpuguy83 My bad! I will read the docs... :)

@vincentwoo
Copy link
Contributor

@alexlarsson is there a good primer out there on how to use Docker with OverlayFS? I've got the 3.18 kernel installed, but am confused about what needs to happen before docker can use OverlayFS.

@jessfraz
Copy link
Contributor

Adding the daemon flag -s overlay is all you need

On Thursday, December 25, 2014, Vincent Woo notifications@github.com
wrote:

@alexlarsson https://github.com/alexlarsson is there a good primer out
there on how to use Docker with OverlayFS? I've got the 3.18 kernel
installed, but am confused about what needs to happen before docker can use
OverlayFS.


Reply to this email directly or view it on GitHub
#7619 (comment).

@vincentwoo
Copy link
Contributor

@jfrazelle Hm, maybe you can help me out with this then. I'm running 3.18:

root@execute1:~# uname -a
Linux execute1 3.18.1-031801-generic #201412170637 SMP Wed Dec 17 11:38:50 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

And have the following block in /etc/default/docker

# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="-s overlayfs"

But when docker tries to start:

root@execute1:~# cat /var/log/upstart/docker.log
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
root@execute1:~# docker --version
Docker version 1.4.1, build 5bc2ff8

@jessfraz
Copy link
Contributor

It's overlay not overlayfs, we changed the name when the kernel did

On Thursday, December 25, 2014, Vincent Woo notifications@github.com
wrote:

@jfrazelle https://github.com/jfrazelle Hm, maybe you can help me out
with this then. I'm running 3.18:

root@execute1:~# uname -a
Linux execute1 3.18.1-031801-generic #201412170637 SMP Wed Dec 17 11:38:50 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

And have the following block in /etc/default/docker

Use DOCKER_OPTS to modify the daemon startup options.

DOCKER_OPTS="-s overlayfs"

But when docker tries to start:

root@execute1:# cat /var/log/upstart/docker.log
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
FATA[0000] driver not supported
root@execute1:
# docker --version
Docker version 1.4.1, build 5bc2ff8


Reply to this email directly or view it on GitHub
#7619 (comment).

@vincentwoo
Copy link
Contributor

oh christ I'm an idiot

@codyi
Copy link

codyi commented Dec 25, 2014

body {
width: 100% !important; min-width: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0;
}
.ExternalClass {
width: 100%;
}
.ExternalClass {
line-height: 100%;
}
#backgroundTable {
margin: 0; padding: 0; width: 100% !important; line-height: 100% !important;
}
img {
outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block;
}
body {
color: #222222; font-family: "Helvetica", "Arial", sans-serif; font-weight: normal; padding: 0; margin: 0; text-align: left; line-height: 1.3;
}
body {
font-size: 14px; line-height: 19px;
}
a:hover {
color: #2795b6 !important;
}
a:active {
color: #2795b6 !important;
}
a:visited {
color: #2ba6cb !important;
}
h1 a:active {
color: #2ba6cb !important;
}
h2 a:active {
color: #2ba6cb !important;
}
h3 a:active {
color: #2ba6cb !important;
}
h4 a:active {
color: #2ba6cb !important;
}
h5 a:active {
color: #2ba6cb !important;
}
h6 a:active {
color: #2ba6cb !important;
}
h1 a:visited {
color: #2ba6cb !important;
}
h2 a:visited {
color: #2ba6cb !important;
}
h3 a:visited {
color: #2ba6cb !important;
}
h4 a:visited {
color: #2ba6cb !important;
}
h5 a:visited {
color: #2ba6cb !important;
}
h6 a:visited {
color: #2ba6cb !important;
}
table.button:hover td {
background: #2795b6 !important;
}
table.button:visited td {
background: #2795b6 !important;
}
table.button:active td {
background: #2795b6 !important;
}
table.button:hover td a {
color: #fff !important;
}
table.button:visited td a {
color: #fff !important;
}
table.button:active td a {
color: #fff !important;
}
table.button:hover td {
background: #2795b6 !important;
}
table.tiny-button:hover td {
background: #2795b6 !important;
}
table.small-button:hover td {
background: #2795b6 !important;
}
table.medium-button:hover td {
background: #2795b6 !important;
}
table.large-button:hover td {
background: #2795b6 !important;
}
table.button:hover td a {
color: #ffffff !important;
}
table.button:active td a {
color: #ffffff !important;
}
table.button td a:visited {
color: #ffffff !important;
}
table.tiny-button:hover td a {
color: #ffffff !important;
}
table.tiny-button:active td a {
color: #ffffff !important;
}
table.tiny-button td a:visited {
color: #ffffff !important;
}
table.small-button:hover td a {
color: #ffffff !important;
}
table.small-button:active td a {
color: #ffffff !important;
}
table.small-button td a:visited {
color: #ffffff !important;
}
table.medium-button:hover td a {
color: #ffffff !important;
}
table.medium-button:active td a {
color: #ffffff !important;
}
table.medium-button td a:visited {
color: #ffffff !important;
}
table.large-button:hover td a {
color: #ffffff !important;
}
table.large-button:active td a {
color: #ffffff !important;
}
table.large-button td a:visited {
color: #ffffff !important;
}
table.secondary:hover td {
background: #d0d0d0 !important; color: #555;
}
table.secondary:hover td a {
color: #555 !important;
}
table.secondary td a:visited {
color: #555 !important;
}
table.secondary:active td a {
color: #555 !important;
}
table.success:hover td {
background: #457a1a !important;
}
table.alert:hover td {
background: #970b0e !important;
}
body.outlook p {
display: inline !important;
}
body {
color: #222222; font-family: "Verdana", "Helvetica", "Arial", sans-serif;
}
.rating a:active {
text-decoration: underline; color: #ffffff !important;
}
.rating a:visited {
text-decoration: underline; color: #ffffff !important;
}
.rating a:hover {
color: #000000 !important;
}
@media only screen and (max-width: 600px) {
table[class="body"] img {
width: auto !important; height: auto !important;
}
table[class="body"] center {
min-width: 0 !important;
}
table[class="body"] .container {
width: 95% !important;
}
table[class="body"] .row {
width: 100% !important; display: block !important;
}
table[class="body"] .wrapper {
display: block !important; padding-right: 0 !important;
}
table[class="body"] .columns {
table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important;
}
table[class="body"] .column {
table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important;
}
table[class="body"] .wrapper.first .columns {
display: table !important;
}
table[class="body"] .wrapper.first .column {
display: table !important;
}
table[class="body"] table.columns td {
width: 100% !important;
}
table[class="body"] table.column td {
width: 100% !important;
}
table[class="body"] .columns td.one {
width: 8.333333% !important;
}
table[class="body"] .column td.one {
width: 8.333333% !important;
}
table[class="body"] .columns td.two {
width: 16.666666% !important;
}
table[class="body"] .column td.two {
width: 16.666666% !important;
}
table[class="body"] .columns td.three {
width: 25% !important;
}
table[class="body"] .column td.three {
width: 25% !important;
}
table[class="body"] .columns td.four {
width: 33.333333% !important;
}
table[class="body"] .column td.four {
width: 33.333333% !important;
}
table[class="body"] .columns td.five {
width: 41.666666% !important;
}
table[class="body"] .column td.five {
width: 41.666666% !important;
}
table[class="body"] .columns td.six {
width: 50% !important;
}
table[class="body"] .column td.six {
width: 50% !important;
}
table[class="body"] .columns td.seven {
width: 58.333333% !important;
}
table[class="body"] .column td.seven {
width: 58.333333% !important;
}
table[class="body"] .columns td.eight {
width: 66.666666% !important;
}
table[class="body"] .column td.eight {
width: 66.666666% !important;
}
table[class="body"] .columns td.nine {
width: 75% !important;
}
table[class="body"] .column td.nine {
width: 75% !important;
}
table[class="body"] .columns td.ten {
width: 83.333333% !important;
}
table[class="body"] .column td.ten {
width: 83.333333% !important;
}
table[class="body"] .columns td.eleven {
width: 91.666666% !important;
}
table[class="body"] .column td.eleven {
width: 91.666666% !important;
}
table[class="body"] .columns td.twelve {
width: 100% !important;
}
table[class="body"] .column td.twelve {
width: 100% !important;
}
table[class="body"] td.offset-by-one {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-two {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-three {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-four {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-five {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-six {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-seven {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-eight {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-nine {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-ten {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-eleven {
padding-left: 0 !important;
}
table[class="body"] table.columns td.expander {
width: 1px !important;
}
table[class="body"] .right-text-pad {
padding-left: 10px !important;
}
table[class="body"] .text-pad-right {
padding-left: 10px !important;
}
table[class="body"] .left-text-pad {
padding-right: 10px !important;
}
table[class="body"] .text-pad-left {
padding-right: 10px !important;
}
table[class="body"] .hide-for-small {
display: none !important;
}
table[class="body"] .show-for-desktop {
display: none !important;
}
table[class="body"] .show-for-small {
display: inherit !important;
}
table[class="body"] .hide-for-desktop {
display: inherit !important;
}
}
@media screen {
@font-face {
font-family: 'Roboto Slab'; font-style: normal; font-weight: 700; src: local('Roboto Slab Bold'), local('RobotoSlab-Bold'), url(http://themes.googleusercontent.com/static/fonts/robotoslab/v3/dazS1PrQQuCxC3iOAJFEJRbnBKKEOwRKgsHDreGcocg.woff) format('woff');
}
}

                Email Delivery Failure Notice  























                What Happened? There was an issue delivering your message to:  























                 mail@liguosong.com   























                Why? The domain name of the email address is not valid  























                     Advertisement |  Prefer no ads?  























                What's next?  
































               Check the "liguosong.com" part of the email address for misspellings or missing letters. (If you find an error, you might need to correct it in your contacts list or address book too.) 
































               If necessary, contact your recipient another way (e.g., phone or text message) to confirm their email address. 























                 Prefer step by step assistance?   























                 Learn more about this bounce message    























                Rate this email:  Helpful  Somewhat helpful  Not helpful  



























                     bounce.io  908 Main Street, Suite 360, Louisville, Colorado Copyright © 2014 bounce.io, All rights reserved. Help

@jessfraz
Copy link
Contributor

No worries! It was overlayfs in this PR and we switched it after ;)

On Thursday, December 25, 2014, Vincent Woo notifications@github.com
wrote:

oh christ I'm an idiot


Reply to this email directly or view it on GitHub
#7619 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet