checkAllContainers: false = only running containers are considered
437808
private String findContainerId(String imageNameOrAlias, boolean checkAllContainers) throws DockerAccessException {
        String id = lookupContainer(imageNameOrAlias);

        // check for external container. The image name is interpreted as a *container name* for that case ...
        if (id == null) {
            Container container = queryService.getContainer(imageNameOrAlias);
            if (container != null && (checkAllContainers || container.isRunning())) {
                id = container.getId();
            }
        }
        return id;
    }
1064627
def containers_running(get_container_name):
    
    running = []
    for n in ['web', 'postgres', 'solr', 'datapusher', 'redis']:
        info = docker.inspect_container(get_container_name(n))
        if info and not info['State']['Running']:
            running.append(n + '(halted)')
        elif info:
            running.append(n)
    return running
645222
private boolean checkRestrictorService(RestrictorCheck pCheck, Object ... args) {
        try {
            ServiceReference[] serviceRefs = bundleContext.getServiceReferences(Restrictor.class.getName(),null);
            if (serviceRefs != null) {
                boolean ret = true;
                boolean found = false;
                for (ServiceReference serviceRef : serviceRefs) {
                    Restrictor restrictor = (Restrictor) bundleContext.getService(serviceRef);
                    if (restrictor != null) {
                        ret = ret && pCheck.check(restrictor,args);
                        found = true;
                    }
                }
                return found && ret;
            } else {
                return false;
            }
        } catch (InvalidSyntaxException e) {
            // Will not happen, since we dont use a filter here
            throw new IllegalArgumentException("Impossible exception (we don't use a filter for fetching the services)",e);
        }
    }
1069722
@Override
	public boolean isMachineRunning( TargetHandlerParameters parameters, String machineId )
	throws TargetException {

		boolean result = false;
		try {
			DockerClient dockerClient = DockerUtils.createDockerClient( parameters.getTargetProperties());
			ContainerState state = DockerUtils.getContainerState( machineId, dockerClient );
			result = state != null && extractBoolean( state.getRunning());

		} catch( Exception e ) {
			// nothing, we consider it is not running
			Utils.logException( this.logger, e );
		}

		return result;
	}
62873
public void checkEmptyContainers() {

        if (getWidgetCount() == 0) {
            if (m_emptyContainerElement != null) {
                m_emptyContainerElement.getStyle().clearDisplay();
            } else if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_containerData.getEmptyContainerContent())) {
                // add empty container element
                try {
                    m_emptyContainerElement = CmsDomUtil.createElement(m_containerData.getEmptyContainerContent());
                    getElement().appendChild(m_emptyContainerElement);
                } catch (Exception e) {
                    CmsDebugLog.getInstance().printLine(e.getMessage());
                }
            }
        } else if (m_emptyContainerElement != null) {
            m_emptyContainerElement.removeFromParent();
            m_emptyContainerElement = null;
        }
    }
775689
def _container_whitelist(self):
        """"""
        if self.__container_whitelist is None:
            self.__container_whitelist = \
                set(self.CLOUD_BROWSER_CONTAINER_WHITELIST or [])
        return self.__container_whitelist
989715
function checkDocker() {
    if (this.abort || this.skipChecks) return;
    const done = this.async();

    shelljs.exec('docker -v', { silent: true }, (code, stdout, stderr) => {
        if (stderr) {
            this.log(
                chalk.red(
                    'Docker version 1.10.0 or later is not installed on your computer.\n' +
                        '         Read http://docs.docker.com/engine/installation/#installation\n'
                )
            );
            this.abort = true;
        } else {
            const dockerVersion = stdout.split(' ')[2].replace(/,/g, '');
            const dockerVersionMajor = dockerVersion.split('.')[0];
            const dockerVersionMinor = dockerVersion.split('.')[1];
            if (dockerVersionMajor < 1 || (dockerVersionMajor === 1 && dockerVersionMinor < 10)) {
                this.log(
                    chalk.red(
                        `${'Docker version 1.10.0 or later is not installed on your computer.\n' +
                            '         Docker version found: '}${dockerVersion}\n` +
                            '         Read http://docs.docker.com/engine/installation/#installation\n'
                    )
                );
                this.abort = true;
            } else {
                this.log.ok('Docker is installed');
            }
        }
        done();
    });
}
724692
private boolean matchContainerWithPendingRequest(final Container container) {

    if (this.requestsAfterSentToRM.isEmpty()) {
      return false;
    }

    final AMRMClient.ContainerRequest request = this.requestsAfterSentToRM.peek();

    final boolean resourceCondition = container.getResource().getMemory() >= request.getCapability().getMemory();

    // TODO[JIRA REEF-35]: check vcores once YARN-2380 is resolved
    final boolean nodeCondition = request.getNodes() == null
        || request.getNodes().contains(container.getNodeId().getHost());

    final boolean rackCondition = request.getRacks() == null
        || request.getRacks().contains(this.nodeIdToRackName.get(container.getNodeId().toString()));

    return resourceCondition && (request.getRelaxLocality() || rackCondition && nodeCondition);
  }
1105618
def container_running(self, container_name):
        
        filters = {
            "name": container_name,
            "status": "running",
        }

        for container in self.client.containers.list(filters=filters):
            if container_name == container.name:
                return container
        return None
183116
def _start_remaining_containers(self, containers_remaining, tool_d):
        
        s_containers = []
        f_containers = []
        for container in containers_remaining:
            s_containers, f_containers = self._start_container(container,
                                                               tool_d,
                                                               s_containers,
                                                               f_containers)
        return (s_containers, f_containers)
1266676
def check_server_running(pid):
    
    if pid == os.getpid():
        # special case--we're in Docker or some other kind of container
        # (or we got really unlucky and got the same PID twice).
        # this PID does not correspond to another running server, either way.
        return False

    try:
        os.kill(pid, 0)
        return True
    except OSError as oe:
        if oe.errno == errno.ESRCH:
            return False
        else:
            raise
1204360
def start_service_containers(self, service, attach):
        
        if not isinstance(service, Service):
            TypeError("Service must be a instance of Service.")

        if not service.containers:
            raise AttributeError("Must load containers before attempting to start them.")

        containers = self.find_service_containers(service)
        if containers:
            for name, container in six.iteritems(containers):
                # TODO: add function to container obj to see if its running.
                if container.state().get('running'):
                    container.stop()

        for name, container in six.iteritems(service.containers):
            if not container.start(attach=attach):
                logger.error("service container: {0} failed to start.".format(name))
                container.dump_logs()

                return False

        return True
1330660
public boolean isCacheContainer(String cacheContainerName) throws Exception {
        Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_INFINISPAN);
        String haystack = CACHE_CONTAINER;
        return null != findNodeInList(addr, haystack, cacheContainerName);
    }
1208314
function isOrContains(container, node)
			{
			    while (node != null)
			    {
			        if (node === container)
			        {
			            return true;
			        }
			        
			        node = node.parentNode;
			    }
			    
			    return false;
			}
441100
def dockerPredicate(e):
    
    if not isinstance(e, subprocess.CalledProcessError):
        return False
    if e.returncode == 125:
        return True
303606
@Override
  public void onContainersCompleted(final List<ContainerStatus> completedContainers) {
    for (final ContainerStatus containerStatus : completedContainers) {
      this.onContainerStatus(containerStatus);
    }
  }
346631
def list_containers(active=True, defined=True,
                    as_object=False, config_path=None):
    

    if config_path:
        if not os.path.exists(config_path):
            return tuple()
        try:
            entries = _lxc.list_containers(active=active, defined=defined,
                                           config_path=config_path)
        except ValueError:
            return tuple()
    else:
        try:
            entries = _lxc.list_containers(active=active, defined=defined)
        except ValueError:
            return tuple()

    if as_object:
        return tuple([Container(name, config_path) for name in entries])
    else:
        return entries