Skip to content

Commit

Permalink
remove prefix "/" from container name
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Oct 27, 2020
1 parent b4e77d6 commit 4b42ba4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ func (c *cLab) Exec(ctx context.Context, id string, cmd []string) ([]byte, []byt
}

// DeleteContainer tries to stop a container then remove it
func (c *cLab) DeleteContainer(ctx context.Context, name string, cid string, timeout time.Duration) error {
func (c *cLab) DeleteContainer(ctx context.Context, name string, timeout time.Duration) error {
force := false
err := c.DockerClient.ContainerStop(ctx, cid, &timeout)
err := c.DockerClient.ContainerStop(ctx, name, &timeout)
if err != nil {
log.Errorf("could not stop container '%s': %v", name, err)
force = true
}
log.Infof("Removing container: %s", name)
err = c.DockerClient.ContainerRemove(ctx, cid, types.ContainerRemoveOptions{Force: force})
err = c.DockerClient.ContainerRemove(ctx, name, types.ContainerRemoveOptions{Force: force})
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ var destroyCmd = &cobra.Command{
defer wg.Done()
name := cont.ID
if len(cont.Names) > 0 {
name = cont.Names[0]
name = strings.TrimLeft(cont.Names[0], "/")
}
log.Infof("Stopping container: %s", name)
err = c.DeleteContainer(ctx, name, cont.ID, 30*time.Second)
err = c.DeleteContainer(ctx, name, 30*time.Second)
if err != nil {
log.Errorf("could not remove container '%s': %v", name, err)
}
Expand Down

0 comments on commit 4b42ba4

Please sign in to comment.