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

Create tmpfs mount in a container from any directory #28273

Closed
CsatariGergely opened this issue Jun 30, 2016 · 7 comments
Closed

Create tmpfs mount in a container from any directory #28273

CsatariGergely opened this issue Jun 30, 2016 · 7 comments
Labels
kind/support Categorizes issue or PR as a support question. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@CsatariGergely
Copy link

Docker implemented the support to mount tmpfs volume on top of any directory in a container (see 1). Kubernetes should also support this functionality by exposing this possibility on its API.
This would be needed to allow --read-only containers, but the content of these directories could be still modified.

@Random-Liu
Copy link
Member

@CsatariGergely Have you checked the Memory mode emptyDir, which mounts tmpfs into specified directory in container. http://kubernetes.io/docs/user-guide/volumes/#emptydir

@Random-Liu Random-Liu added the kind/support Categorizes issue or PR as a support question. label Jun 30, 2016
@janosi
Copy link
Contributor

janosi commented Jun 30, 2016

@Random-Liu The --tmpfs option on the Docker API is about moving the content of an existing directory of a container into tmpfs when the container is started. E.g. /run or /var (or any other directory, of course). So, it preserves the content of the directory, and at the same time it moves that into a tmpfs.
I think, it is not possible with emptyDir.

@Random-Liu
Copy link
Member

Random-Liu commented Jun 30, 2016

The --tmpfs flag mounts an empty tmpfs into the container.

https://docs.docker.com/engine/reference/commandline/run/#/mount-tmpfs-tmpfs

@janosi I can't tell there is any difference with emptyDir.

I also tried my self:

$ sudo docker run -it --tmpfs /var busybox ls /var
$ sudo docker run -it busybox ls /var
spool  www

@janosi
Copy link
Contributor

janosi commented Jun 30, 2016

@Random-Liu Please refer to [1], "Other cool stuff".
I.e. if the directory exists in the container image, the content of that is tar'd and moved into the new (and true, initially empty) tmpfs.

[1] http://www.projectatomic.io/blog/2015/12/making-docker-images-write-only-in-production/

@j3ffml j3ffml added sig/node Categorizes an issue or PR as relevant to SIG Node. team/ux labels Jun 30, 2016
@pwittrock pwittrock removed the team/ux label Jul 18, 2016
@janosi
Copy link
Contributor

janosi commented Sep 2, 2016

We have a chance to work on this issue now. I would like to align the design before applying it on the code.
The change on the versioned API would look like this (/pkg/api/v1/types.go). Your comments are welcome!

There would be the following new field in type Container

//Optional. Cannot be changed. Support of Docker function --tmpfs to enable in-memory modification of
//some data in a read-only container. The listed mount points will be backed by a tmpfs. If a mount
//point exists in the container image the content of that is preserved when the tmpfs is created.
//Keeping the content is achieved by using tar on the existing content. For this reason "tar" shall
//be available and executable in the container.
TmpFsList []TmpFs `json:"tmpFsList,omitempty"`

There would be a new type TmpFs to allow the description of the target TmpFs mount point:

// TmpFs describes a tmpfs mount point in a container.
type TmpFs struct {
        // This must match the Name of a Volume.
        MountPath string `json:"mountPath"`
        // Mounted read-only if true, read-write otherwise (false or unspecified).
        // Defaults to false.
        ReadOnly bool `json:"readOnly,omitempty"`
        //noexec flag for tmpfs. Defaults to false.
        NoExec bool `json:"noExec,omitempty"`
        //nosuid flag for tmpfs. Defaults to false.
        NoSuId bool `json:"noSuId,omitempty"`
        //size of the tmpfs. Defaults to the amount of memory on the host.
        Size   *resource.Quantity `json:"size,omitempty"`
        //access mode. Default value is according to umask setting.
        Mode   string `json:"mode,omitempty"`
}

@janosi
Copy link
Contributor

janosi commented Sep 5, 2016

Please just ignore and close this issue.
It turned out, that in Docker removed the support of tar'ing the content of an existing dir in 1.10-rc2. Please see 1. Without that, it is really just an emptyDir.
Thank you!

@xiangpengzhao
Copy link
Contributor

cc @thockin

@thockin thockin closed this as completed May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

No branches or pull requests

7 participants