Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

852
Views
How to set uid and gid in Docker Compose?

I can execute a docker run command as such ...

docker run --rm  --user $(id -u):$(id -g) -e MYDATA=/some/path/to/data -e USER=$USER -p 8883-8887:8883-8887 ...

However, in Docker Compose, when I write out the following ...

version: '3.7'
services:
  container_name: some-server
  image: some:img
  user: $(id -u):$(id -g) 
  ... 

... it does not work.

I understand I am asking docker-compose up to perform sub shell command substitution, and it cannot.

Is there any way to do this?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Try this

So, you need to put:

user: "${UID}:${GID}"

in your docker compose and provide UID and GID as docker-compose parameter

UID=${UID} GID=${GID} docker-compose up

(or define UID and GID as environment variables).

over 4 years ago · Santiago Trujillo Report

0

This can be done as well

In your docker-composer.yml

user: $DOCKER_USER

In the command line

echo 'export DOCKER_USER="$(id -u):$(id -g)"' >> ~/.bash_profile

source ~/.bash_profile

docker-compose up

Created a DOCKER_USER variable and added it in the bash_profile for persistency. The source will help the shell to recognize changes of .bash_profile on demand

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!