code: @Override
      public final void after() {
          log.debug("after {}", containerShortId);
          try {
              dockerLogs.close();
              ContainerState state = dockerClient.inspectContainer(container.id()).state();
              log.debug("{} state {}", containerShortId, state);
              if (state.running()) {
                  if (builder.stopOptions().contains(StopOption.KILL)) {
                      dockerClient.killContainer(container.id());
                      log.info("{} killed", containerShortId);
                  } else {
                      dockerClient.stopContainer(container.id(), STOP_TIMEOUT);
                      log.info("{} stopped", containerShortId);
                  }
              }
              if (builder.stopOptions().contains(StopOption.REMOVE)) {
                  dockerClient.removeContainer(container.id(), DockerClient.RemoveContainerParam.removeVolumes());
                  log.info("{} deleted", containerShortId);
                  container = null;
              }
          } catch (DockerException | InterruptedException e) {
              throw new IllegalStateException(e);
          }
      }
docs: Stop and remove container.<br/>
  This is {@link ExternalResource#before()} made available as public - it may be helpful in scenarios
  when you want to use {@link DockerRule} and operate it manually.