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

249
Vistas
How to mount current directory as read-only but still allow changes inside the container?

I have a situation where:

  • I want to mount a directory ~/tmp/mycode to /mycode readonly
  • I want to be able to edit the files in the directory, so I can't just run -v /my/local/path/tmp/mycode:/mycode
    • I want it to not persist changes on the host filesystem though so I can't mount it read/write
  • ~/tmp/mycode is rather large

Basically I want to be able to edit the files in the mounted volume but not have those changes persisted.

My current workflow is to create a dummy container using a dockerfile:

ADD . /mycode

and then execute that container.

However as the repository grows, this step takes longer and longer to perform, because the only way I can think is to make a complete copy of ~/tmp/mycode in order to be able to manipulate the files in the container.

I've also thought about mounting the directory and copying it inside the container and committing that container, but that has the same issue.

Is there a way to run a docker container to allow file edits without persisting them on the host short of copying the whole directory?

I am using the latest docker for mac, currently Version 17.03.1-ce-mac5 (16048).

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is fairly trivial to do with docker and overlay:

docker run --name myenv --privileged -v /my/local/path/tmp/mycode:/mnt/rocode:ro -it ubuntu /bin/bash
docker exec -d myenv /sbin/mount -t overlay overlay -o lowerdir=/mnt/rocode,upperdir=/mycode,workdir=/mnt/code-workdir /mycode

This should mount the code from your directory read only and create the overlay inside the container so that /mnt/rocode is read only, but /mycode is writable.

Make sure that your kernel is 3.18+ and that you have overlay in your /proc/filesystems.

about 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