Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

284
Visualizações
Docker permissions host user volume in the container

I'm looking for a "clean" solution to share a volume and share the permissions. I mean, if it's possible, I would like to have the same user in my container than the local user who has started it.

Currently, I'm using:

docker run --rm -v ~/Projects/:/projects/ mycontainer

It works but the problem is, when my container writes some content in this volume, it's root who is the proprietary and not my local user.

What is the best way to handle this issue? If it's possible, I don't want to create user information in the Dockerfile, because I want to share this container with colleagues and I want to avoid any permissions issue between the local user and the container user.

Thanks

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can specify the user on the docker run command:

--user, -u      Username or UID (format: <name|uid>[:<group|gid>])

If you use the numeric UID and GID of the host user, the created files will belong to it.

over 4 years ago · Santiago Trujillo Relatório

0

Thank for your help Henry.

My complete solution was:

docker run --rm -e USER_ID=$(echo "$UID") -v ~/Projects/:/projects/ mycontainer

And I've this script as entrypoint value:

#!/bin/bash
adduser -D -u $USER_ID alpine &>/dev/null
cd /projects/
su alpine -c 'mycommand ...."

With this my container can access and add/modify content in the Projects folder with the same permissions as my local user.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda