DEV Community

Discussion on: Specifying user and group in Docker

Collapse
 
varunbatrait profile image
Varun Batra

Any way without export UID?

Collapse
 
acro5piano profile image
Kay Gosho

env UID=${UID} GID=${GID} docker-compose up would work without export UID, I suppose!

Collapse
 
varunbatrait profile image
Varun Batra

Hi, if I do this, on restart (if I have docker always restart) permission is lost on system boot. Hence, this isn't a good way to do it.

Thread Thread
 
acro5piano profile image
Kay Gosho

Hi Varun,

Oh really? I don't have such experiences, as file permission usually doesn't change on system boot.

Thread Thread
 
varunbatrait profile image
Varun Batra • Edited

Hi

Let us say that you have a docker container which will keep creating files with some logic - in my case it is compressing the images.

I have written a blog for the docker I have added to a tool:

Lossless Image Compressions using Docker

Now what it does is - it reads image - move image to temp folder, compress it, copy back to its original location.

All goes well as I have started it with $UID as mentioned in your post.

However, let us say now the machine is restarted - somehow $UID becomes a root.

If you have observed the same problem? After restart - some images I uploaded are now compressed with the root user and not www-data as originally intended.

Thread Thread
 
acro5piano profile image
Kay Gosho

Sorry for my slow response.

I didn't investigate the problem deeply, and moving files to /tmp or such directory, and restart the machine.

Actually I recently don't use Docker on Linux with daily development. In production we don't store data to disk so don't care about the permissions.