Troubleshooting
From Genesys Documentation
This topic is part of the manual Running Containers and Troubleshooting for version Current of Genesys Docker Documentation.
Information about how to troubleshoot docker containers.
Troubleshooting Docker Containers
- Get the IP address. To do this, run the following command.
Or, install jQuery and run the following command.
docker inspect $(dl) | grep -wm1 IPAddress | cut -d '"' -f 4
Or install go template and run the following command.docker inspect $(dl) | jq -r '.[0].NetworkSettings.IPAddress'
To pass a build argument when building an image from Dockerfile:docker inspect -f '{{ .NetworkSettings.IPAddress }}' <container_name>DOCKER_HOST_IP=`ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1` echo DOCKER_HOST_IP = $DOCKER_HOST_IP docker build \ --build-arg ARTIFACTORY_ADDRESS=$DOCKER_HOST_IP -t sometag \ some-directory/ - Get port mapping
docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' <containername> - Find containers by regular expression
for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done
- Get environment settings.
docker run --rm ubuntu env
- Kill running containers.
docker kill $(docker ps -q)
- Delete all containers (force!! running or stopped containers).
docker rm -f $(docker ps -qa)
- Delete old containers.
docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs docker rm - Delete stopped containers.
docker rm -v $(docker ps -a -q -f status=exited)
- Delete containers after stopping.
docker stop $(docker ps -aq) && docker rm -v $(docker ps -aq)
- Delete dangling images.
docker rmi $(docker images -q -f dangling=true)
- Delete all images.
docker rmi $(docker images -q)
- Delete dangling volumes.
As of Docker 1.9.0:
In 1.9.0, the filter dangling=false does not work. It is ignored and lists all volumes.
docker volume rm $(docker volume ls -q -f dangling=true)
- Show image dependencies.
docker images -viz | dot -Tpng -o docker.png
- Slimming down Docker containers.
Cleaning APT in a RUN layer:
This must be done in the same layer as that of the other APT commands. If not, the previous layers will still contain the original information and your images will still be large.
RUN {apt commands} \&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Flatten an image:
ID=$(docker run -d image-name /bin/bash)
docker export $ID | docker import – flat-image-name
For backup:
ID=$(docker run -d image-name /bin/bash)
(docker export $ID | gzip -c > image.tgz)
gzip -dc image.tgz | docker import - flat-image-name
Information on Running Docker Containers
docker psdisplays running containers.docker logsgets logs from the container. (You can use a custom log driver, but logs are available only for json-file and journald in 1.10).docker inspectinspects all the information of a container (including the IP address).docker eventsgets events from the container.docker portdisplays the public facing port of the container.docker topdisplays the running processes in container.docker statsdisplays the containers' resource usage statistics.docker diffdisplays the changed files in the container's FS.docker ps -adisplays running and stopped containers.docker stats --alldisplays a running list of containers.docker updateupdates a container's resource limits.
To check the CPU, memory, and network I/O usage of a single container:
docker stats <container>For all containers listed by ID:
docker stats $(docker ps -q)For all containers listed by name:
docker stats $(docker ps --format '{{.Names}}')For all containers listed by image:
docker ps -a -f ancestor=ubuntuTo remove all untagged images:
docker rmi $(docker images | grep “^” | awk '{split($0,a," "); print a[3]}')To remove container by a regular expression:
docker ps -a | grep wildfly | awk '{print $1}' | xargs docker rm -fTo remove all exited containers:
docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')Comments or questions about this documentation? Contact us for support!