mirror of
https://github.com/apple/container.git
synced 2026-07-21 00:41:32 +00:00
Throw error when starting a container with invalid virtiofs source (#1051)
Run = Create + Start 1) Mount source points to a valid directory - Run and Create + Start both correctly create the container with mount. 2) Mount source points to a file - Run fails bootstrapping the container, thus container not created. - Create creates the container, but Start fails bootstrapping, removing the container. (Thus, both are the same.) 3) Mount source deleted or replaced to file after container created - Start throw errors but do not delete the container.
This commit is contained in:
@@ -18,6 +18,7 @@ import ArgumentParser
|
||||
import ContainerAPIClient
|
||||
import ContainerizationError
|
||||
import ContainerizationOS
|
||||
import Foundation
|
||||
import TerminalProgress
|
||||
|
||||
extension Application {
|
||||
@@ -69,6 +70,12 @@ extension Application {
|
||||
return
|
||||
}
|
||||
|
||||
for mount in container.configuration.mounts where mount.isVirtiofs {
|
||||
if !FileManager.default.fileExists(atPath: mount.source) {
|
||||
throw ContainerizationError(.invalidState, message: "path '\(mount.source)' is not a directory")
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
let io = try ProcessIO.create(
|
||||
tty: container.configuration.initProcess.terminal,
|
||||
|
||||
Reference in New Issue
Block a user