aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_commit.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-04-30 08:26:31 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-30 21:07:59 +0000
commit9924956dc88bf91a4d0bf09249ffb4cb960dee01 (patch)
tree19c45c97a8af4ef47a65d28dcbf9a6ce5e2d1f77 /libpod/container_commit.go
parentc8c39779a7919e78a97b97394930080885a41425 (diff)
downloadpodman-9924956dc88bf91a4d0bf09249ffb4cb960dee01.tar.gz
podman-9924956dc88bf91a4d0bf09249ffb4cb960dee01.tar.bz2
podman-9924956dc88bf91a4d0bf09249ffb4cb960dee01.zip
do not commit default volumes from container
when performing a container commit, we should not add the default list of volumes for a container to the resulting image. it will cause the resulting image to crash when run subsequently. Signed-off-by: baude <bbaude@redhat.com> Closes: #699 Approved by: mheon
Diffstat (limited to 'libpod/container_commit.go')
-rw-r--r--libpod/container_commit.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/libpod/container_commit.go b/libpod/container_commit.go
index a227e0987..e9004bcb2 100644
--- a/libpod/container_commit.go
+++ b/libpod/container_commit.go
@@ -26,7 +26,7 @@ type ContainerCommitOptions struct {
// Commit commits the changes between a container and its image, creating a new
// image
-func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*image.Image, error) {
+func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions, mounts, command, entryPoint []string) (*image.Image, error) {
if !c.batched {
c.lock.Lock()
defer c.lock.Unlock()
@@ -74,11 +74,15 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
// add it to the resulting image.
// Entrypoint - always set this first or cmd will get wiped out
- importBuilder.SetEntrypoint(c.Spec().Process.Args)
+ if len(entryPoint) > 0 {
+ importBuilder.SetEntrypoint(entryPoint)
+ }
+
// Cmd
- // We cannot differentiate between cmd and entrypoint here
- // so we assign args to both
- importBuilder.SetCmd(c.Spec().Process.Args)
+ if len(command) > 0 {
+ importBuilder.SetCmd(command)
+ }
+
// Env
for _, e := range c.config.Spec.Process.Env {
splitEnv := strings.Split(e, "=")
@@ -96,8 +100,10 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
// User
importBuilder.SetUser(c.User())
// Volumes
- for _, v := range c.config.Spec.Mounts {
- importBuilder.AddVolume(v.Source)
+ for _, v := range mounts {
+ if v != "" {
+ importBuilder.AddVolume(v)
+ }
}
// Workdir
importBuilder.SetWorkDir(c.Spec().Process.Cwd)