Docker Community Forums

Share and learn in the Docker community.

Change directory permission in docker container and preserving them

I have an image and a container from it. They both run ok at the local docker host level.
I do have some issues about changing existing directory permission inside the running container and then preserving the changes.

I would like to know the proper approach to change and preserve directory perms changes in containers.

I start the container01 from template01 with
docker run -d -p 0.0.0.0:8080:80 -it --name container01 template01 bash

then connect to it with: docker attach container01
then inside I do: chmod 777 /somedir
then I detach from the container and do: docker commit container01ID template02

but when I run a new container based on the template02, the perm changes to /somedir are not preserved.

What is the proper way to do the changes and preserve them?

thanks,

Hi @eaperezh,

Let me ask you a question. Why yo a trying to change a directory permission on a container?
Create a dockerfile with the “FROM template01”, then in the RUN statement execute de chmod.
After that, build the Dockerfile and tag it as “template02”. This should preserve the new directory permission in the new Image.

PS: Sorry for my bad English

1 Like

Thanks / GRacias @mgvazquez
That is exactly what I am traying to accomplish. I do believe this is an “english” problem from my side. Not being able to clearly explain my goals.
But yes, the way you mention it (and as I am still in the learning rocess) is they way I want to “preserve” the permission.

Una vez mas muchas gracias!

@eaperezh hablas español? :thinking:
Si es así, va a ser mas fácil darte una mano.

I agree that the correct way to do this is by using the Dockerfile but I am wondering why the process you are describing is not working. Are you mapping in any volumes or anything like that?