Skip to content

--tmpfs fails with Permission denied and noexec is an invalid option #18853

Closed

Description

@konstruktoid

From https://github.com/rhatdan/docker/blob/b3e527dfd242ad30c0297c8b257862116cf2c50e/integration-cli/docker_cli_run_unix_test.go#L449:
dockerCmdWithError("run", "--tmpfs", "/run:noexec,nosuid,rw,size=5k,mode=700", "busybox", "touch", "/run/somefile"

$ docker run -ti -d --tmpfs /run:noexec,nosuid,rw,size=5k,mode=700 busybox touch /run/somefile
ab98b4ed8753270e95da880a912f021da7109a8e8e3ad42bb93fdfdd8d9d996f
$ docker run -ti -d --tmpfs /run:noexec busybox touch /run/somefile
docker: Invalid tmpfs option [""].
See 'docker run --help'.
$ docker run -ti -d --tmpfs /etc:noexec,nosuid,rw,size=5k,mode=700 busybox touch /tmp/somefile
75da9ade4b9dda3fb05ec915f440da38ce7e63b4d4e0796d4ca855fdfc38e158
docker: Error response from daemon: Cannot start container 75da9ade4b9dda3fb05ec915f440da38ce7e63b4d4e0796d4ca855fdfc38e158: [9] System error: configs.Command{Path:"/bin/tar", Args:[]string{"-cf", "/var/lib/docker/0.0/tmp/75da9ade4b9dda3fb05ec915f440da38ce7e63b4d4e0796d4ca855fdfc38e158018870457/_etc.tar", "-C", "/var/lib/docker/0.0/overlay/422b1cf19ddb33115ffa6de37784313271ae21ad474e7913652de234a705ef01/merged/etc", "."}, Env:[]string(nil), Dir:""} failed: /bin/tar: /var/lib/docker/0.0/overlay/422b1cf19ddb33115ffa6de37784313271ae21ad474e7913652de234a705ef01/merged/etc: Cannot open: Permission denied
/bin/tar: Error is not recoverable: exiting now
: exit status 2.
$ docker run --rm --tmpfs /etc:noexec busybox uname -a
docker: Invalid tmpfs option [""].
See 'docker run --help'.

The logs below are generated with https://gist.github.com/konstruktoid/d5444c76cf502c795c29.

:: Mount a tmpfs to verify basic tmpfs works

mount: none mounted on /tmp/tmpfstest.
none on /tmp/tmpfstest type tmpfs (rw,relatime,size=1048576k)
WORKS.

:: Create a testfile in the tmpfs

-rw------- 1 tsj tsj 29 Dec 22 18:02 /tmp/tmpfstest/pewpew
Tue Dec 22 17:02:41 UTC 2015

:: debian::wheezy container uname*

Linux 68afdf9c84ff 4.2.0-18-generic #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 x86_64 GNU/Linux
WORKS.

:: debian::wheezy container uname w readonly filesystem*

Linux 1f58e9fa95eb 4.2.0-18-generic #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 x86_64 GNU/Linux
WORKS.

:: debian::wheezy container uname with --tmpfs /etc*

Timestamp: 2015-12-22 18:02:42.721797302 +0100 CET
Code: System error

Message: configs.Command{Path:"/bin/tar", Args:[]string{"-cf", "/var/lib/docker/0.0/tmp/f66afbe8ccb867494bbcf746beda6325f6627823af1b660fe02b267a195e724a143435614/_etc.tar", "-C", "/var/lib/docker/0.0/overlay/4953cb98fc3b7f9512a9fbaacafc43068f18c32e8c70249e72b24a8d246de358/merged/etc", "."}, Env:[]string(nil), Dir:""} failed: /bin/tar: /var/lib/docker/0.0/overlay/4953cb98fc3b7f9512a9fbaacafc43068f18c32e8c70249e72b24a8d246de358/merged/etc: Cannot open: Permission denied
/bin/tar: Error is not recoverable: exiting now
: exit status 2

Frames:

---
0: setupRootfs
Package: github.com/opencontainers/runc/libcontainer
File: rootfs_linux.go@36

---
1: Init
Package: github.com/opencontainers/runc/libcontainer.(*linuxStandardInit)
File: standard_init_linux.go@57

---
2: StartInitialization
Package: github.com/opencontainers/runc/libcontainer.(*LinuxFactory)
File: factory_linux.go@243

---
3: initializer
Package: github.com/docker/docker/daemon/execdriver/native
File: init.go@35

---
4: Init
Package: github.com/docker/docker/pkg/reexec
File: reexec.go@26

---
5: main
Package: main
File: docker.go@18

---
6: main
Package: runtime
File: proc.go@111

---
7: goexit
Package: runtime
File: asm_amd64.s@1721
docker: Error response from daemon: Cannot start container f66afbe8ccb867494bbcf746beda6325f6627823af1b660fe02b267a195e724a: [9] System error: configs.Command{Path:"/bin/tar", Args:[]string{"-cf", "/var/lib/docker/0.0/tmp/f66afbe8ccb867494bbcf746beda6325f6627823af1b660fe02b267a195e724a143435614/_etc.tar", "-C", "/var/lib/docker/0.0/overlay/4953cb98fc3b7f9512a9fbaacafc43068f18c32e8c70249e72b24a8d246de358/merged/etc", "."}, Env:[]string(nil), Dir:""} failed: /bin/tar: /var/lib/docker/0.0/overlay/4953cb98fc3b7f9512a9fbaacafc43068f18c32e8c70249e72b24a8d246de358/merged/etc: Cannot open: Permission denied
/bin/tar: Error is not recoverable: exiting now
: exit status 2.

:: debian::wheezy container uname with --tmpfs /etc:noexec*

docker: Invalid tmpfs option [""].
See 'docker run --help'.

:: debian::wheezy container uname with --tmpfs /etc:rw,nosuid using sudo*

docker: Invalid tmpfs option [""].
See 'docker run --help'.

:: busybox touch /run/somefile (from tests)
WORKS.

:: busybox fs options touch /run/somefile (from tests)
WORKS.

:: busybox fs --tmpfs /etc

Timestamp: 2015-12-22 18:02:44.308551924 +0100 CET
Code: System error

Message: configs.Command{Path:"/bin/tar", Args:[]string{"-cf", "/var/lib/docker/0.0/tmp/b3d858cf619b1a5e649380c36613dd6f9a1cd99bc029b445cd96aa04d07a54d3087305069/_etc.tar", "-C", "/var/lib/docker/0.0/overlay/c0353ccf10594c403fcbb2d589b6c861171057c1a01015423d7dda30e657d8f8/merged/etc", "."}, Env:[]string(nil), Dir:""} failed: /bin/tar: /var/lib/docker/0.0/overlay/c0353ccf10594c403fcbb2d589b6c861171057c1a01015423d7dda30e657d8f8/merged/etc: Cannot open: Permission denied
/bin/tar: Error is not recoverable: exiting now
: exit status 2

Frames:

---
0: setupRootfs
Package: github.com/opencontainers/runc/libcontainer
File: rootfs_linux.go@36

---
1: Init
Package: github.com/opencontainers/runc/libcontainer.(*linuxStandardInit)
File: standard_init_linux.go@57

---
2: StartInitialization
Package: github.com/opencontainers/runc/libcontainer.(*LinuxFactory)
File: factory_linux.go@243

---
3: initializer
Package: github.com/docker/docker/daemon/execdriver/native
File: init.go@35

---
4: Init
Package: github.com/docker/docker/pkg/reexec
File: reexec.go@26

---
5: main
Package: main
File: docker.go@18

---
6: main
Package: runtime
File: proc.go@111

---
7: goexit
Package: runtime
File: asm_amd64.s@1721
docker: Error response from daemon: Cannot start container b3d858cf619b1a5e649380c36613dd6f9a1cd99bc029b445cd96aa04d07a54d3: [9] System error: configs.Command{Path:"/bin/tar", Args:[]string{"-cf", "/var/lib/docker/0.0/tmp/b3d858cf619b1a5e649380c36613dd6f9a1cd99bc029b445cd96aa04d07a54d3087305069/_etc.tar", "-C", "/var/lib/docker/0.0/overlay/c0353ccf10594c403fcbb2d589b6c861171057c1a01015423d7dda30e657d8f8/merged/etc", "."}, Env:[]string(nil), Dir:""} failed: /bin/tar: /var/lib/docker/0.0/overlay/c0353ccf10594c403fcbb2d589b6c861171057c1a01015423d7dda30e657d8f8/merged/etc: Cannot open: Permission denied
/bin/tar: Error is not recoverable: exiting now
: exit status 2.

*:: busybox --tmpfs /etc:noexec

docker: Invalid tmpfs option [""].
See 'docker run --help'.

:: Docker version

Client:
 Version:      1.10.0-dev
 API version:  1.22
 Go version:   go1.5.2
 Git commit:   8537501
 Built:        Mon Dec 21 20:12:08 2015
 OS/Arch:      linux/amd64
 Experimental: true

Server:
 Version:      1.10.0-dev
 API version:  1.22
 Go version:   go1.5.2
 Git commit:   8537501
 Built:        Mon Dec 21 20:12:08 2015
 OS/Arch:      linux/amd64
 Experimental: true

:: Docker info

Containers: 81
Images: 14
Server Version: 1.10.0-dev
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
 Volume: local
 Network: bridge null host
Kernel Version: 4.2.0-18-generic
Operating System: Ubuntu 15.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.954 GiB
Name: lab01
ID: 6AEH:63II:LVVM:TZPI:LSSA:U5LL:U27O:XJ22:TBY6:6BKS:MTEX:PVEG
WARNING: No swap limit support
Experimental: true

:: Docker group
docker:x:999:tsj

:: Host information
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
Linux lab01 4.2.0-18-generic #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Activity

  1. thaJeztah commented on Dec 22, 2015

    @thaJeztah
    Member
  2. added
    kind/bug
    on Dec 22, 2015
  3. rhatdan commented on Dec 22, 2015

    @rhatdan
    Contributor

    The above patch should fix

    docker run --rm --tmpfs /etc:noexec busybox uname -a
    

    What were the docker run commands used to create the other failures?

  4. rhatdan commented on Dec 22, 2015

    @rhatdan
    Contributor

    Never mind, I just grabbed your script. I ran it on Fedora/Rawhide (f24) and It is successful with the above patch.

    # sh /tmp/testtmpfs.sh
    \n*:: Mount a tmpfs to verify basic tmpfs works*
    mount: none mounted on /tmp/tmpfstest.
    none on /tmp/tmpfstest type tmpfs (rw,relatime,seclabel,size=1048576k)
    WORKS.
    \n*:: Create a testfile in the tmpfs*
    -rw-r--r--. 1 root root 29 Dec 22 14:07 /tmp/tmpfstest/pewpew
    Tue Dec 22 19:07:14 UTC 2015
    \n*:: debian*::wheezy container uname*
    Linux eb38f01844bd 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 GNU/Linux
    WORKS.
    \n*:: debian*::wheezy container uname w readonly filesystem*
    Linux 6278db9ea592 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 GNU/Linux
    WORKS.
    \n*:: debian*::wheezy container uname with --tmpfs /etc*
    Linux be2094aad3b9 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 GNU/Linux
    WORKS.
    \n*:: debian*::wheezy container uname with --tmpfs /etc:noexec*
    Linux f74aedc640f8 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 GNU/Linux
    WORKS.
    \n*:: debian*::wheezy container uname with --tmpfs /etc:rw,nosuid using sudo*
    Linux 97b3e3c2df94 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 GNU/Linux
    WORKS.
    \n*:: busybox touch /run/somefile (from tests)*
    WORKS.
    \n*:: busybox fs options touch /run/somefile (from tests)*
    WORKS.
    \n*:: busybox fs --tmpfs /etc*
    WORKS.
    \n*:: busybox --tmpfs /etc:noexec
    WORKS.
    \n*:: Docker version*
    Client:
     Version:      1.10.0-dev
     API version:  1.22
     Go version:   go1.5.2
     Git commit:   81c8e4d-dirty
     Built:        Tue Dec 22 13:56:05 2015
     OS/Arch:      linux/amd64
    
    Server:
     Version:      1.10.0-dev
     API version:  1.22
     Go version:   go1.5.2
     Git commit:   81c8e4d-dirty
     Built:        Tue Dec 22 13:56:05 2015
     OS/Arch:      linux/amd64
    \n*:: Docker info*
    Containers: 15
    Images: 44
    Server Version: 1.10.0-dev
    Storage Driver: devicemapper
     Pool Name: docker-8:2-3014703-pool
     Pool Blocksize: 65.54 kB
     Base Device Size: 10.74 GB
     Backing Filesystem: xfs
     Data file: /dev/loop0
     Metadata file: /dev/loop1
     Data Space Used: 1.026 GB
     Data Space Total: 107.4 GB
     Data Space Available: 72.76 GB
     Metadata Space Used: 1.987 MB
     Metadata Space Total: 2.147 GB
     Metadata Space Available: 2.145 GB
     Udev Sync Supported: true
     Deferred Removal Enabled: false
     Deferred Deletion Enabled: false
     Deferred Deleted Device Count: 0
     Data loop file: /var/lib/docker/devicemapper/devicemapper/data
     WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
     Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
     Library Version: 1.02.113 (2015-12-05)
    Execution Driver: native-0.2
    Logging Driver: journald
    Plugins: 
     Volume: local
     Network: bridge null host
    Kernel Version: 4.4.0-0.rc5.git3.1.fc24.x86_64
    Operating System: Fedora 24 (Workstation Edition)
    OSType: linux
    Architecture: x86_64
    CPUs: 4
    Total Memory: 7.478 GiB
    Name: dhcp-10-19-62-196.boston.devel.redhat.com
    ID: QCJD:BQVE:IUG3:CFBA:4EKW:A3RD:JUR2:7VOG:XWP6:2ELL:KMIY:E5JM
    \n*:: Docker group*
    docker:x:975:
    \n*:: Host information*
    LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
    Distributor ID: Fedora
    Description:    Fedora release 24 (Rawhide)
    Release:    24
    Codename:   Rawhide
    Linux dhcp-10-19-62-196.boston.devel.redhat.com 4.4.0-0.rc5.git3.1.fc24.x86_64 #1 SMP Fri Dec 18 16:47:01 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
  5. rhatdan commented on Dec 22, 2015

    @rhatdan
    Contributor

    What OS were you running your tests on. If that OS has a version of tar that is failing it could be causing some issues.

  6. konstruktoid commented on Dec 22, 2015

    @konstruktoid
    ContributorAuthor
    $ tar --version
    tar (GNU tar) 1.27.1
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 15.10
    Release:        15.10
    Codename:       wily
    $ uname -a
    Linux lab01 4.2.0-18-generic #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  7. rhatdan commented on Dec 22, 2015

    @rhatdan
    Contributor

    @konstruktoid Could you try your test with my patch applied to see if it fixes the issue.

  8. konstruktoid commented on Dec 23, 2015

    @konstruktoid
    ContributorAuthor

    Thanks @rhatdan, the issue with noexec has been fixed with your patch and the permission issues was caused by the Docker apparmor policy, even though it was in complain-mode...
    Removing that policy, and --tmpfs works just great.

    :: Mount a tmpfs to verify basic tmpfs works
    mount: none mounted on /tmp/tmpfstest.
    none on /tmp/tmpfstest type tmpfs (rw,relatime,size=1048576k)
    WORKS.

    :: Create a testfile in the tmpfs
    -rw-rw-r-- 1 tabd tabd 29 Dec 23 09:33 /tmp/tmpfstest/pewpew
    Wed Dec 23 08:33:56 UTC 2015

    :: debian::wheezy container uname
    Linux 5f3933655c26 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 GNU/Linux
    WORKS.

    :: debian::wheezy container uname w readonly filesystem
    Linux 126ae76ff4b1 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 GNU/Linux
    WORKS.

    :: debian::wheezy container uname with --tmpfs /etc
    Linux 1f7bec15f7ee 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 GNU/Linux
    WORKS.

    :: debian::wheezy container uname with --tmpfs /etc:noexec
    Linux 0477585ce49e 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 GNU/Linux
    WORKS.

    :: debian::wheezy container uname with --tmpfs /etc:rw,nosuid using sudo
    Linux 3c99d87ad9ee 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 GNU/Linux
    WORKS.

    :: busybox touch /run/somefile (from tests)
    WORKS.

    :: busybox fs options touch /run/somefile (from tests)
    WORKS.

    :: busybox fs --tmpfs /etc
    WORKS.

    :: busybox --tmpfs /etc:noexec
    WORKS.

    :: busybox --tmpfs /run:noexec
    WORKS.

    :: busybox --tmpfs /tmp:noexec
    WORKS.

    :: Docker version
    Client:
    Version: 1.10.0-dev
    API version: 1.22
    Go version: go1.5.2
    Git commit: 1105caa
    Built: Wed Dec 23 08:18:14 2015
    OS/Arch: linux/amd64

    Server:
    Version: 1.10.0-dev
    API version: 1.22
    Go version: go1.5.2
    Git commit: 1105caa
    Built: Wed Dec 23 08:18:14 2015
    OS/Arch: linux/amd64

  9. thaJeztah commented on Dec 23, 2015

    @thaJeztah
    Member

    @konstruktoid do we need changes in the AppArmor policy?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions