()
| 149 | } |
| 150 | |
| 151 | func (s *ConcreteService) Stop() error { |
| 152 | if !s.isExpectedRunning() { |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | logger.Log("Stopping", s.name) |
| 157 | |
| 158 | if out, err := RunCommandAndGetOutput("docker", "stop", "--time=30", s.containerName()); err != nil { |
| 159 | logger.Log(string(out)) |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | s.Wait() |
| 164 | |
| 165 | // Ensure the container is fully removed before returning. Even though |
| 166 | // containers are started with --rm, Docker removes them asynchronously |
| 167 | // after the process exits. Without this explicit removal, restarting a |
| 168 | // container with the same name can fail with "name already in use". |
| 169 | _, _ = RunCommandAndGetOutput("docker", "rm", "--force", s.containerName()) |
| 170 | |
| 171 | s.usedNetworkName = "" |
| 172 | |
| 173 | return nil |
| 174 | } |
| 175 | |
| 176 | func (s *ConcreteService) Kill() error { |
| 177 | if !s.isExpectedRunning() { |
nothing calls this directly
no test coverage detected