From 8b0a418d86ea1743b168d5e96217fd40ae30debe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 3 Aug 2018 20:20:21 +0200 Subject: [PATCH] (#43) Pass container name to remove container method --- cmd/rm.go | 2 +- docker/docker.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/rm.go b/cmd/rm.go index 10a15f9..8bf35c6 100644 --- a/cmd/rm.go +++ b/cmd/rm.go @@ -65,7 +65,7 @@ var rmReleaseCmd = &cobra.Command{ // removeDockerContainer removes the running container func removeDockerContainer(image liferay.Image) { - err := docker.RemoveDockerContainer(image) + err := docker.RemoveDockerContainer(image.GetContainerName()) if err != nil { log.Fatalln("Impossible to remove the container [" + image.GetContainerName() + "]") } diff --git a/docker/docker.go b/docker/docker.go index 210db26..37ea37a 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -180,13 +180,12 @@ func PullDockerImage(dockerImage string) { } } -// RemoveDockerContainer removes the running container -func RemoveDockerContainer(image liferay.Image) error { +// RemoveDockerContainer removes a running container +func RemoveDockerContainer(containerName string) error { dockerClient := getDockerClient() return dockerClient.ContainerRemove( - context.Background(), image.GetContainerName(), - types.ContainerRemoveOptions{ + context.Background(), containerName, types.ContainerRemoveOptions{ RemoveVolumes: true, Force: true, }) @@ -217,7 +216,7 @@ func RunDockerImage( if CheckDockerContainerExists(image) { log.Println("The container [" + image.GetContainerName() + "] is running.") - _ = RemoveDockerContainer(image) + _ = RemoveDockerContainer(image.GetContainerName()) } port := fmt.Sprintf("%d", httpPort)