()
| 174 | } |
| 175 | |
| 176 | func (s *ConcreteService) Kill() error { |
| 177 | if !s.isExpectedRunning() { |
| 178 | return nil |
| 179 | } |
| 180 | |
| 181 | logger.Log("Killing", s.name) |
| 182 | |
| 183 | if out, err := RunCommandAndGetOutput("docker", "kill", s.containerName()); err != nil { |
| 184 | logger.Log(string(out)) |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | s.Wait() |
| 189 | |
| 190 | // Ensure the container is fully removed before returning. Even though |
| 191 | // containers are started with --rm, Docker removes them asynchronously |
| 192 | // after the process exits. Without this explicit removal, restarting a |
| 193 | // container with the same name can fail with "name already in use". |
| 194 | _, _ = RunCommandAndGetOutput("docker", "rm", "--force", s.containerName()) |
| 195 | |
| 196 | s.usedNetworkName = "" |
| 197 | |
| 198 | return nil |
| 199 | } |
| 200 | |
| 201 | // Wait waits until the service is stopped. |
| 202 | func (s *ConcreteService) Wait() { |
nothing calls this directly
no test coverage detected