0402e0fdbe
Funciones Docker: list/start/stop/remove containers, list/pull/remove images, inspect, logs, run. Tipos: ContainerInfo e ImageInfo. Pre-existentes en el dominio infra, ahora registrados.
23 lines
524 B
Go
23 lines
524 B
Go
package infra
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
// DockerRemoveContainer elimina un contenedor Docker. Si force es true, fuerza la eliminación de contenedores en ejecución.
|
|
func DockerRemoveContainer(nameOrID string, force bool) error {
|
|
args := []string{"rm"}
|
|
if force {
|
|
args = append(args, "-f")
|
|
}
|
|
args = append(args, nameOrID)
|
|
|
|
out, err := exec.Command("docker", args...).CombinedOutput()
|
|
if err != nil {
|
|
return fmt.Errorf("docker rm %s: %s", nameOrID, strings.TrimSpace(string(out)))
|
|
}
|
|
return nil
|
|
}
|