Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda