Difference between revisions of "Docker/Current/Troubleshooting/Troubleshooting"

From Genesys Documentation
Jump to: navigation, search
m (Text replacement - "\|Platform=([^\|]*)GenesysEngage-onpremises([\|]*)" to "|Platform=$1GenesysEngage-cloud$2")
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{ArticleUnstructured
 
{{ArticleUnstructured
 +
|Standalone=No
 
|DisplayName=Troubleshooting
 
|DisplayName=Troubleshooting
|Platform=GenesysEngage-cloud, PureConnect, GenesysCloud
+
|Platform=PureConnect, GenesysCloud, GenesysEngage-cloud
|Context=Information about how to troubleshoot docker containers.
+
|Context=How to troubleshoot docker containers
|Standalone=No
 
 
}}
 
}}
 +
{{NoteFormat|
 +
The following content has been deprecated and is maintained for reference only.
 +
|3}}
 
==Troubleshooting Docker Containers==
 
==Troubleshooting Docker Containers==
 +
{{{!}} class="wikitable"
 +
{{!}}-
 +
{{!}} style="width: 799.2px;" data-mce-style="width: 799.2px;"{{!}}'''Note:''' At the end of this topic, you will be provided with a terminal to an environment that has all the prerequisites (such as Docker and Kubernetes) up and running. You can practice your commands in this tutorial without any need to setup your own environment.<br />
 +
{{!}}}
 +
 +
 
<ol>
 
<ol>
<li>Get the IP address. To do this, run the following command.
 
<source lang="xml"> docker inspect $(dl) | grep -wm1 IPAddress | cut -d '"' -f 4</source>Or, install jQuery and run the following command.
 
<source lang="xml">docker inspect $(dl) | jq -r '.[0].NetworkSettings.IPAddress'</source>Or install [https://docs.docker.com/engine/reference/commandline/inspect go template] and run the following command. <source lang="xml">docker inspect -f '{{ .NetworkSettings.IPAddress }}' <container_name></source> To pass a build argument when building an image from Dockerfile:
 
<source lang="xml">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/
 
</source></li>
 
<li>Get port mapping
 
<source lang="xml">docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' <containername></source></li>
 
<li>Find containers by regular expression
 
<source lang="xml">for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done</source></li>
 
 
<li>Get environment settings.  
 
<li>Get environment settings.  
 
<source lang="xml">docker run --rm ubuntu env</source></li>
 
<source lang="xml">docker run --rm ubuntu env</source></li>
Line 43: Line 38:
 
<li> Show image dependencies.
 
<li> Show image dependencies.
 
<source lang="xml">docker images -viz | dot -Tpng -o docker.png</source></li>
 
<source lang="xml">docker images -viz | dot -Tpng -o docker.png</source></li>
<li>Slimming down Docker containers.
+
<li>Slim down Docker containers.<br>
 
'''Cleaning APT in a RUN layer''':
 
'''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.
 
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.
Line 58: Line 53:
 
</ol>
 
</ol>
  
== Information on Running Docker Containers ==
+
==Information on Running Docker Containers==
* <code>docker ps</code> displays running containers.
+
 
* <code>docker logs</code> gets logs from the container. (You can use a custom log driver, but logs are available only for json-file and journald in 1.10).
+
*<code>docker ps</code> displays running containers.
* <code>docker inspect</code> inspects all the information of a container (including the IP address).
+
*<code>docker logs</code> gets logs from the container. (You can use a custom log driver, but logs are available only for json-file and journald in 1.10).
* <code>docker events</code> gets events from the container.
+
*<code>docker inspect</code> inspects all the information of a container (including the IP address).
* <code>docker port</code> displays the public facing port of the container.
+
*<code>docker events</code> gets events from the container.
* <code>docker top</code> displays the running processes in container.
+
*<code>docker port</code> displays the public facing port of the container.
* <code>docker stats</code> displays the containers' resource usage statistics.
+
*<code>docker top</code> displays the running processes in container.
* <code>docker diff</code> displays the changed files in the container's FS.
+
*<code>docker stats</code> displays the containers' resource usage statistics.
* <code>docker ps -a</code> displays running and stopped containers.
+
*<code>docker diff</code> displays the changed files in the container's FS.
* <code>docker stats --all</code> displays a running list of containers.
+
*<code>docker ps -a</code> displays running and stopped containers.
* <code>docker update</code> updates a container's resource limits.
+
*<code>docker stats --all</code> displays a running list of containers.
 +
*<code>docker update</code> updates a container's resource limits.
  
 
To check the CPU, memory, and network I/O usage of a single container:
 
To check the CPU, memory, and network I/O usage of a single container:
Line 85: Line 81:
 
To remove all exited containers:
 
To remove all exited containers:
 
<source lang="xml">docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')</source>
 
<source lang="xml">docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')</source>
 +
You can practice the above-mentioned commands using the following widget:
 +
{{#widget:Katacoda|divid=myScenario|scenario=docker/deploying-first-container|height=800px}}

Latest revision as of 09:30, December 3, 2024

This topic is part of the manual Running Containers and Troubleshooting for version Current of Genesys Docker Documentation.


How to troubleshoot docker containers

Warning

The following content has been deprecated and is maintained for reference only.

Troubleshooting Docker Containers

Note: At the end of this topic, you will be provided with a terminal to an environment that has all the prerequisites (such as Docker and Kubernetes) up and running. You can practice your commands in this tutorial without any need to setup your own environment.


  1. Get environment settings.
    docker run --rm ubuntu env
  2. Kill running containers.
    docker kill $(docker ps -q)
  3. Delete all containers (force!! running or stopped containers).
    docker rm -f $(docker ps -qa)
  4. Delete old containers.
    docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs docker rm
  5. Delete stopped containers.
    docker rm -v $(docker ps -a -q -f status=exited)
  6. Delete containers after stopping.
    docker stop $(docker ps -aq) && docker rm -v $(docker ps -aq)
  7. Delete dangling images.
    docker rmi $(docker images -q -f dangling=true)
  8. Delete all images.
    docker rmi $(docker images -q)
  9. Delete dangling volumes. As of Docker 1.9.0:
    docker volume rm $(docker volume ls -q -f dangling=true)
    In 1.9.0, the filter dangling=false does not work. It is ignored and lists all volumes.
  10. Show image dependencies.
    docker images -viz | dot -Tpng -o docker.png
  11. Slim 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 ps displays running containers.
  • docker logs gets 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 inspect inspects all the information of a container (including the IP address).
  • docker events gets events from the container.
  • docker port displays the public facing port of the container.
  • docker top displays the running processes in container.
  • docker stats displays the containers' resource usage statistics.
  • docker diff displays the changed files in the container's FS.
  • docker ps -a displays running and stopped containers.
  • docker stats --all displays a running list of containers.
  • docker update updates 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=ubuntu

To 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 -f

To remove all exited containers:

docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')

You can practice the above-mentioned commands using the following widget:

Comments or questions about this documentation? Contact us for support!