Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

chmod of home directory : "permission denied" on overlayfs, works with aufs (OSX / DockerMachine) #3327

Description

@dieswaytoofast

(docker-machine version: 0.7.0; VirtualBox version: 5.0.16 r105871; OSX version: 10.11.4 (15E65))

A newly created user can't chmod their home directory if the storage-driver is overlayfs. It works perfectly with aufs though.
This isn't restricted to home directories. Users can not change permissions on the 'top-most' directory they own.
e.g. Given A / B / C (with A owned by root, and B and C owned by someuser), someuser can change permissions on C, but not on B

Note that there are no host-mounted directories, volumes, etc. This is with a default/baseline ubuntu container...

To test this

Overlay
Create the machine
paglierino:mahesh$ docker-machine create -d virtualbox --engine-storage-driver=overlay dev
Connect to the machine, and start up ubuntu

paglierino:mahesh$ docker-machine ssh default
docker@default:~$ docker run -it ubuntu /bin/bash

Add a user

root@61448047d92a:/# adduser --disabled-password --uid 501 --home /var/lib/postgresql --shell /bin/bash --gecos 'PostgreSQL administrator' postgres
Adding user `postgres' ...
Adding new group `postgres' (501) ...
Adding new user `postgres' (501) with group `postgres' ...
Creating home directory `/var/lib/postgresql' ...
Copying files from `/etc/skel' ...

Try to change permissions for that user, and fial

root@61448047d92a:/# su - postgres
postgres@61448047d92a:~$ pwd
/var/lib/postgresql
postgres@61448047d92a:~$ ls -ald .
drwxr-xr-x 2 postgres postgres 4096 Apr 16 20:16 .
postgres@61448047d92a:~$ chmod 700 .
chmod: changing permissions of '.': Operation not permitted
postgres@61448047d92a:~$ ls -ald .
drwxr-xr-x 2 postgres postgres 4096 Apr 16 20:16 

aufs
Create the machine
paglierino:mahesh$ docker-machine create -d virtualbox --engine-storage-driver=aufs notdev
Connect to the machine, and start up ubuntu

paglierino:mahesh$ docker-machine ssh notdev
docker@default:~$ docker run -it ubuntu /bin/bash

Add a user

root@9ec0a58c827e:/# adduser --disabled-password --uid 501 --home /var/lib/postgresql --shell /bin/bash --gecos 'PostgreSQL administrator' postgres
Adding user `postgres' ...
Adding new group `postgres' (501) ...
Adding new user `postgres' (501) with group `postgres' ...
Creating home directory `/var/lib/postgresql' ...
Copying files from `/etc/skel' ...

Try to change permissions for that user, and profit

root@1f32cac40882:/# su - postgres
postgres@1f32cac40882:~$ ls -ald .
drwxr-xr-x 2 postgres postgres 4096 Apr 16 20:15 .
postgres@1f32cac40882:~$ pwd
/var/lib/postgresql
postgres@1f32cac40882:~$ chmod 700 .
postgres@1f32cac40882:~$ ls -ald .
drwx------ 2 postgres postgres 4096 Apr 16 20:15 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions