Docker Container Errors — Exit Codes, OOMKilled, and Networking Issues
About Docker Container Errors
Fix Docker container errors including non-zero exit codes, OOMKilled, DNS resolution inside containers, port binding conflicts, and volume permission issues. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Docker exit codes indicate why a container stopped: 0 (success), 1 (app error), 137 (killed/OOM), 139 (segfault). OOMKilled occurs when a container exceeds its memory limit set by --memory flag or system OOM. DNS resolution inside containers uses Docker's embedded DNS server (127.0.0.11). Port binding fails if the host port is already in use by another process or container. Volume permissions issues arise when container user UID does not match host file ownership. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Container running out of memory (OOMKilled with exit code 137). Application crash inside the container (exit code 1, check container logs). Port conflict: host port already bound by another container or host process. DNS resolution failing inside container due to Docker network misconfiguration. Volume mount permissions: container process runs as different UID than host file owner. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check container status: docker ps -a to see exit codes of stopped containers. View container logs: docker logs <container_id> --tail 100. Check if OOMKilled: docker inspect <container_id> | grep OOMKilled. Fix port conflicts: docker port <container> to see port mappings, or change host port. Fix DNS: add --dns 8.8.8.8 to docker run or configure /etc/docker/daemon.json. Fix volume permissions: match container user UID with host UID, or use --user flag in docker run. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What does exit code 137 mean?
Exit code 137 means the process was killed by signal 9 (SIGKILL). Usually this is the OOM killer terminating the process for exceeding memory limits. Increase --memory or optimize the application.
Overview
Fix Docker container errors including non-zero exit codes, OOMKilled, DNS resolution inside containers, port binding conflicts, and volume permission issues.
Key Details
- Docker exit codes indicate why a container stopped: 0 (success), 1 (app error), 137 (killed/OOM), 139 (segfault)
- OOMKilled occurs when a container exceeds its memory limit set by --memory flag or system OOM
- DNS resolution inside containers uses Docker's embedded DNS server (127.0.0.11)
- Port binding fails if the host port is already in use by another process or container
- Volume permissions issues arise when container user UID does not match host file ownership
Common Causes
- Container running out of memory (OOMKilled with exit code 137)
- Application crash inside the container (exit code 1, check container logs)
- Port conflict: host port already bound by another container or host process
- DNS resolution failing inside container due to Docker network misconfiguration
- Volume mount permissions: container process runs as different UID than host file owner
Steps
- 1Check container status: docker ps -a to see exit codes of stopped containers
- 2View container logs: docker logs <container_id> --tail 100
- 3Check if OOMKilled: docker inspect <container_id> | grep OOMKilled
- 4Fix port conflicts: docker port <container> to see port mappings, or change host port
- 5Fix DNS: add --dns 8.8.8.8 to docker run or configure /etc/docker/daemon.json
- 6Fix volume permissions: match container user UID with host UID, or use --user flag in docker run