Skip to content

titan doesn't clean up containers in the CREATED state #93

@eschrock

Description

@eschrock

If you have a port conflict when trying to clone a container, then you'll end up with the container in the Created state. The clone will fail and try to clean it up, but it doesn't end up deleting the container:

                println("Removing container $container")
                if (docker.containerIsRunning(container)) {
                    docker.rm(container, force)
                } else  {
                    docker.rmStopped(container)
                }
            }

    fun containerIsRunning(container: String): Boolean {
        val result = executor.exec(listOf("docker", "ps", "-f", "name=$container", "--format", "\"{{.Names}}\""))
        return result.isNotEmpty()
    }

    fun rmStopped(container:String): String {
        val containerId = executor.exec(listOf("docker", "ps", "-f", "status=exited", "-f", "name=$container", "--format", "{{.ID}}")).trim()
        return executor.exec(listOf("docker", "container", "rm", containerId))
    }

If you’re stuck in the “CREATED” state, you are not running, but also not exited. Think we should always just be doing a forced rm, not sure why we're filtering by status=exited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions