Skip to content

Commit

Permalink
(#43) Pass container name to remove container method
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Aug 3, 2018
1 parent a8ea533 commit 8b0a418
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() + "]")
}
Expand Down
9 changes: 4 additions & 5 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8b0a418

Please sign in to comment.