testcontainers / testcontainers/testcontainers-java
Starting docker-compose test containers as non-root user
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
Similar to: https://github.com/testcontainers/testcontainers-java/issues/2590
I'm trying to start our docker-compose based testcontainers tests, and pass in the local username from the running system, in order that the container can write files to mounted volumes with the correct permissions.
I tried a compose with:
version: "3.7"
services:
myservice:
image: xxx
user: ${CURRENT_USER}
...
volumes:
./target/:/target
And passed in CURRENT_USER environment variable to testcontainers using:
env = new DockerComposeContainer(new File("src/main/docker/docker-compose.yml"));
env.withLocalCompose(true);
env.withEnv("CURRENT_USER", System.getProperty("user.name"));
However, this fails with:
Cannot start service my server: unable to find user bmiddleton: no matching entries in passwd file
I presume it's looking for that user in the ryuk container, and not the OS - where the user does exist.
How can I get a testcontainers test running from a docker compose file to write its files using the current user of the operating system?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la configurazione di DockerComposeContainer usando src/main/docker/docker-compose.yml, includendo withLocalCompose(true) e withEnv("CURRENT_USER", System.getProperty("user.name")). Riproduci il fallimento del test basato su Compose e verifica come vengono gestiti l’utente del servizio Compose e il volume ./target/ montato. Il lavoro è completato quando il servizio può scrivere i file montati con i permessi dell’utente OS corrente senza l’errore di lookup in passwd.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, docker-compose, java
- Ambito
- devops, testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100