Run container with different user
Feriman22 opened this issue · 4 comments
Hi,
How can I define Group ID and User ID in Docker Compose to change the permissions of files uploaded to a volume? Is there a variable to do this?
Thanks,
Feriman
Hi, same problem, when i change user et group id via user option, i got the following errors :
tp-server | addgroup: permission denied (are you root?)
ftp-server | adduser: permission denied (are you root?)
ftp-server | chown: unknown user/group ftpuser:ftpuser
ftp-server | chpasswd: permission denied (are you root?)
ftp-server | touch: /var/log/vsftpd.log: Permission denied
ftp-server | tail: can't open '/var/log/vsftpd.log': No such file or directory
ftp-server | tail: no files
ftp-server | touch: /var/log/xferlog: Permission denied
ftp-server | tail: can't open '/var/log/xferlog': No such file or directory
ftp-server | tail: no files
ftp-server exited with code 0
Finally, I discovered a workaround. By default, the UID and GID are set to 1000:1000. However, you can override these values using the UID and GID environment variables. For example, in my docker-compose.yml file.
version: '3.7'
services:
ftp:
container_name: ftp-server
image: garethflowers/ftp-server
environment:
- 'FTP_USER=${FTP_USERNAME}'
- 'FTP_PASS=${FTP_PASSWORD}'
- 'UID=996'
- 'GID=995'
restart: always
ports:
- '20-21:20-21/tcp'
- '40000-40009:40000-40009/tcp'
volumes:
- '/stock/scan/files:/home/${FTP_USERNAME}'
Thx, it works for me too!
Added a quick note for the UID and GID environment variables in the ReadMe.
See 056f99a