mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
Ensure WORKDIR from images is created
A recent crun change stopped the creation of the container's working directory if it does not exist. This is arguably correct for user-specified directories, to protect against typos; it is definitely not correct for image WORKDIR, where the image author definitely intended for the directory to be used. This makes Podman create the working directory and chown it to container root, if it does not already exist, and only if it was specified by an image, not the user. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
@ -1451,6 +1451,19 @@ func WithCreateCommand(cmd []string) CtrCreateOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithCreateWorkingDir tells Podman to create the container's working directory
|
||||
// if it does not exist.
|
||||
func WithCreateWorkingDir() CtrCreateOption {
|
||||
return func(ctr *Container) error {
|
||||
if ctr.valid {
|
||||
return define.ErrCtrFinalized
|
||||
}
|
||||
|
||||
ctr.config.CreateWorkingDir = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Volume Creation Options
|
||||
|
||||
// WithVolumeName sets the name of the volume.
|
||||
|
Reference in New Issue
Block a user