Tactics and Tools for Troubleshooting Docker on Pluralsight

In this course, you will learn the skills you need to reduce the time it takes you to assess and fix the most common Docker errors.

Learn More on Pluralsight

Managing Sitecore Docker Containers on Pluralsight

In this course, you will learn how to develop, manage, and deploy Sitecore Docker containers using Kubernetes, Azure Kubernetes Service, Azure Container Registry, and SearchStax.

Managing Sitecore Docker Containers GitHub Repo

Learn More on Pluralsight

Docker Commands

docker-compose up -dCreates and runs containers in detached mode for all services defined in your docker-compose files.
docker-compose downStop and remove containers.
docker-compose start [container]Start existing containers that are not running.
docker-compose stop [container]Stop but do not remove containers.
docker-compose buildBuild and create images for all services that define a build image.
docker-compose build [service] Build and create images for specific services that define a build image.
docker psList containers.
docker-compose logs -f –tail 20Display logs from all containers limited to 20 lines.
docker exec -it [containername] powershellOpen an interactive shell in a container.
docker rmi $(docker images –format “{{.Repository}}:{{.Tag}}”|findstr “imagename”)Remove all images with a specific name or tag.
docker rmi –allRemove all images.
docker-compose up –force-recreateRecreate containers even if their configuration and image have not changed.
docker-compose -f docker-compose.prod.yml -f docker-compose.prod.override.yml up -dExplicitly specify what docker-compose files to load. All other compose files will be ignored.
docker-compose -f docker-compose.xp0.yml -f docker-compose.xp0.override.yml buildExplicitly specify docker-compose files to build images.
docker-compose -f docker-compose.xp0.yml -f docker-compose.xp0.override.yml downExplicitly specify docker-compose files including the containers you want to take down.
docker system pruneRemoves all unnecessary and unused resources including stopped containers, networks not in use, dangling images, and build caches.
docker tag [image name]:[image version] [new image name]Tag a Docker image
docker push [new image name]Push a Docker image to the image repository you are currently logged into.
docker pull [image name] Pull a Docker image to the image repository you are currently logged into.

Troubleshooting Docker Commands

docker logs –tail 1000 -f –details [container id]Show the last 1000 log entries for the specified container id.
docker logs –tail 1000 -f –since 2022-01-02T01:00:00Z [container id]Show the last 1000 log entries since the date in UTC format for the specified container id.
docker logs –tail 1000 -f –since 60 [container id]Show the last 1000 log entries since the time for the specified container id.
docker logs –tail 1000 -f –until 2022-01-02T01:00:00Z [container id]Show the last 1000 log entries until the date in UTC format for the specified container id.
docker logs –tail 1000 -f –until 60 [container id]Show the last 1000 log entries until the time for the specified container id.
docker logs –tail 1000 -f –timestamps [container id]Show the last 1000 log entries including timestamps for the specified container id.
docker inspect –format='{{.Config.Image}}’ [container id]Return information about images attached to a container.
docker inspect –format='{{.LogPath}}’ [container id]Return the path to the log files within a container.
docker inspect –format='{{json .Config}}’ [container id]Return config information for a container in json format.
docker inspect –format='{{.State.ExitCode}}’ [container id]Return the exit code for a container.
docker inspect –format='{{.Config.Volumes}}’ [container id]Return information about volumes attached to a container.
docker exec -it [container id] [path]Open an interactive shell for a container.
docker export -o [tar file name] [container id]Export files within a container to a tar file.
docker cp [container id]:/ [file path]Copy files within a container to the specified file path.
docker image prune -a -f –filter “until=24h”Prune images created more than 24h ago.
docker image prune -a -f –filter “until=2022-02-01T00:00:00Z” –filter “label=environment”Prune images created before the until date with the label “environment”.
docker run -ti –rm [IMAGE ID] shRun the specified image in an interactive shell.
docker commit [CONTAINER ID] [imagename]Commit a container using the specified image.
docker trust inspect IMAGE[:TAG] [IMAGE[:TAG]…]Inspect the trust configuration for the specified image.
docker secret inspect [OPTIONS] SECRET [SECRET…]Inspect the secret configuration for a named secret.
docker volume lsList all available volumes.
docker volume inspect [container id]Inspect volumes used by the specified container id.
docker system prune –volumesPrune all unused images, containers, networks, and volumes.
docker rm $(docker ps –filter status=exited -q)Remove containers in the exited status.

Troubleshooting Docker Networking

docker network lsList all available networks.
docker network inspect [network name]Inspect a network by name.
docker inspect –format='{{json .NetworkSettings}}’ [container name]Return information about Network Settings for a container in json format.
docker inspect –format='{{json .HostConfig}}’ [container name]Return information about Host Config Settings for a container in json format.
docker inspect –format='{{json .NetworkSettings.Ports}}’ [container name]Return information about Ports assigned to a container in json format.
docker inspect –format='{{json .HostConfig.PortBindings}}’ [container name]Return information about Port Bindings for the Host Config for a container in json format.
docker inspect –format='{{.HostConfig.Dns}}’ [container name]Return information about the DNS Settings for the Host Config for a container.
docker network rm [network name or id]Remove a network by name or Id.
docker network prunePrune unused networks.

Docker Exit Codes

  • Exit Code 0: No foreground process or process completed successfully
  • Exit Code 1: Failure due to an application error
  • Exit Code 125: Docker daemon has encountered an error (ex. malformed command)
  • Exit Code 126: Container command cannot be invoked (ex. script cannot run)
  • Exit Code 127: Container command can’t be found (ex. wrong path to binary)
  • Exit Code 137: Container received SIGKILL (manual container shutdown)
  • Exit Code 139: Container received SIGSEGV (memory access violation)
  • Exit Code 143: Container received SIGTERM (self-terminating process)

Kubernetes Commands

kubectl create -k [k8s file] -n [namespace]Create pods within a namespace using the instructions from the specified k8s file.
kubectl apply -k [k8s file] -n [namespace] Apply changes to pods within a namespace using the instructions from the specified k8s file. If the pod does not exist, it will be created.
kubectl –namespace ingress-basic get services -o wide -w nginx-ingress-ingress-nginx-controllerObtain the external IP address of the ingress controller service.
kubectl get jobs -n [namespace]View the current jobs for the specified namespace.
kubectl get pods -n sitecoreView the status of your pods.
kubectl logsView the logs for your pods.
kubectl delete deploy -n [namespace] [service]Delete the deployment for a service within a namespace.
kubectl delete service -n [namespace] [service] Delete a service within a namespace.
kubectl delete jobs -n [namespace] –allDelete all jobs within a namespace.