public void destroyContainer(Container container, boolean force) { assertValid(); String containerId = container.getId(); LOGGER.info("Destroying container {}", containerId); boolean destroyed = false; try { ContainerProvider provider = getProvider(container, true); if (provider != null) { try { provider.stop(container); } catch (Exception ex) { // Ignore error while stopping and try to destroy. } provider.destroy(container); destroyed = true; } } finally { try { if (destroyed || force) { portService.get().unregisterPort(container); getDataStore().deleteContainer(container.getId()); } } catch (Exception e) { LOGGER.warn( "Failed to cleanup container {} entries due to: {}. This will be ignored.", containerId, e.getMessage()); } } }
public void stopContainer(Container container, boolean force) { assertValid(); LOGGER.info("Stopping container {}", container.getId()); ContainerProvider provider = getProvider(container); provider.stop(container); }