mirror of
https://github.com/containers/podman.git
synced 2025-06-28 06:18:57 +08:00
Merge pull request #11592 from Luap99/runlabel-name
container runlabel remove image tag from name
This commit is contained in:
@ -133,6 +133,9 @@ func generateRunlabelCommand(runlabel string, img *libimage.Image, inputName str
|
|||||||
}
|
}
|
||||||
splitImageName := strings.Split(normalize, "/")
|
splitImageName := strings.Split(normalize, "/")
|
||||||
name = splitImageName[len(splitImageName)-1]
|
name = splitImageName[len(splitImageName)-1]
|
||||||
|
// make sure to remove the tag from the image name, otherwise the name cannot
|
||||||
|
// be used as container name because a colon is an illegal character
|
||||||
|
name = strings.SplitN(name, ":", 2)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the user-specified arguments to the runlabel (command).
|
// Append the user-specified arguments to the runlabel (command).
|
||||||
|
@ -22,6 +22,10 @@ var GlobalDockerfile = fmt.Sprintf(`
|
|||||||
FROM %s
|
FROM %s
|
||||||
LABEL RUN echo \$GLOBAL_OPTS`, ALPINE)
|
LABEL RUN echo \$GLOBAL_OPTS`, ALPINE)
|
||||||
|
|
||||||
|
var PodmanRunlabelNameDockerfile = fmt.Sprintf(`
|
||||||
|
FROM %s
|
||||||
|
LABEL RUN podman run --name NAME IMAGE`, ALPINE)
|
||||||
|
|
||||||
var _ = Describe("podman container runlabel", func() {
|
var _ = Describe("podman container runlabel", func() {
|
||||||
var (
|
var (
|
||||||
tempdir string
|
tempdir string
|
||||||
@ -128,4 +132,18 @@ var _ = Describe("podman container runlabel", func() {
|
|||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container runlabel name removes tag from image", func() {
|
||||||
|
image := "podman-runlabel-name:sometag"
|
||||||
|
podmanTest.BuildImage(PodmanRunlabelNameDockerfile, image, "false")
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(Exit(0))
|
||||||
|
Expect(result.OutputToString()).To(Equal("command: " + podmanTest.PodmanBinary + " run --name podman-runlabel-name localhost/" + image))
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"rmi", image})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(Exit(0))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user