[Bug]: container export -o deletes an existing directory
Los mantenedores suelen responder en 1 día
@devops-thiago ya está trabajando en esto.
Desde el 1/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
Línea de trabajo
Lee Sources/ContainerCommands/Container/ContainerExport.swift alrededor de la limpieza y el traslado mencionados en ContainerExport.run y, después, inspecciona testExportCommandRunningContainerAndOverwrite para entender el comportamiento previsto al reemplazar archivos. Reproduce el problema con -o apuntando a un directorio que contenga un archivo; la tarea está hecha cuando la exportación rechaza ese destino antes de comenzar, mientras que el comportamiento de sobrescritura de archivos existentes sigue cubierto por el test.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I have done the following
- I have searched the existing issues
- If possible, I've reproduced the issue using the 'main' branch of this project
Steps to reproduce
Point -o at a directory that already holds a file:
mkdir -p ~/work/out && echo "keep this" > ~/work/out/notes.txt
container run -d --name web alpine:latest sleep 900
container export -o ~/work/out web
ls -la ~/work
file ~/work/out
The export exits 0 and prints nothing. The directory has been replaced by the archive and notes.txt is gone (paths shortened):
total 17472
drwxr-xr-x@ 3 thiago staff 96 Oct 1 14:27 .
drwxr-xr-x@ 6 thiago staff 192 Oct 1 14:27 ..
-rw-r--r--@ 1 thiago staff 8943104 Oct 1 14:27 out
~/work/out: POSIX tar archive
Before the export, out was a directory holding notes.txt. A debug build of main at 0a48a1b gives the same result.
With -o . the working directory is the one that goes:
mkdir -p ~/work/cwd && echo "keep this" > ~/work/cwd/notes.txt
cd ~/work/cwd && container export -o . web
ls -la ~/work
cwd is now a tar archive of 8943104 bytes and the directory with notes.txt no longer exists.
The removal also comes before the move, so when the move fails the previous output file is lost too. To see it, use a second volume with less free space than the archive (a 24 MB disk image here, filled to 4.3 MiB free):
$ echo old > /Volumes/exptest/out.tar
$ container export -o /Volumes/exptest/out.tar web
Error: “archive.tar” couldn’t be moved to “exptest” because there isn’t enough space.
$ cat /Volumes/exptest/out.tar
cat: /Volumes/exptest/out.tar: No such file or directory
Problem description
After the export has finished, ContainerExport.run clears the destination and moves the archive in:
let outputURL = URL(fileURLWithPath: output!)
if FileManager.default.fileExists(atPath: outputURL.path(percentEncoded: false)) {
try FileManager.default.removeItem(at: outputURL)
}
try FileManager.default.moveItem(at: archive, to: outputURL)
removeItem deletes a directory and everything under it. The option value is resolved against the current directory before this runs, so -o . becomes the working directory and -o ~/projects becomes that folder. Because the removal comes after the export, a long export finishes before the data is gone.
Because removeItem runs before moveItem, any failure of the move, a full volume for example, also leaves nothing at the path.
Replacing an existing file is intended: testExportCommandRunningContainerAndOverwrite exports twice to the same path. A directory should be refused instead, before the export starts.
Environment
- OS: macOS 26.6.2 (25G83)
- Xcode: 26.6 (17F113)
- Container: 1.5.0 (Homebrew), and main at 0a48a1b
Code of Conduct
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Swift
- Estrellas
- 51.1k
- Forks
- 1.8k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 37
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apple/container
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Intermittent failure in PathUtilsTests.testNewDirectoryIsExcludedAndExistingChoiceIsKeptAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
apple/container#2474 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Request]: container ls --filter label=key=valuePosiblemente ocupada @kavix la tomó hace 14 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apple/container#2403 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Request]: Improve robustness and path resolution in ensure-hawkeye.shPosiblemente ocupada @denizguney la tomó hace 38 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
[Bug]: kernel download hangs forever when the server stops sendingPosiblemente ocupada @devops-thiago la tomó hace 40 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
apple/container#2327 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apple/container
Issues similares
-
a: plugins d: docs/ fyi-macos P2 platform-ios platform-macos team-ios
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
swiftlang/github-workflows#352 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
jphacks/kz_2601#1375 · 1 comentario ·
Los mantenedores suelen responder en 1 día