DEV Community

Nico Reyes
Nico Reyes

Posted on

Spent 2 hours fixing Docker. The problem was one word in my config.

Spent 2 hours fixing Docker. The problem was one word in my config.

Was setting up a new project yesterday with Docker Compose. Container kept crashing with zero helpful error messages. Just "exited with code 137".

Searched Stack Overflow for an hour. Everyone said out of memory but my system had 16GB free.

What I tried

First thought it was the image. Rebuilt it 5 times with different base images. Alpine, debian, ubuntu. Still crashed.

Then maybe volume mounts were broken. Changed paths, removed them entirely, added them back. Container still died at startup.

Checked logs. Nothing useful:

app-1  | exited with code 137
app-1 exited with code 137
Enter fullscreen mode Exit fullscreen mode

Fun times.

The actual problem

After way too long staring at my compose file, found it. In the deploy section I had:

deploy:
  resources:
    limits:
      cpus: '1.0'
      memory: 512M  # This line
Enter fullscreen mode Exit fullscreen mode

Changed it to:

deploy:
  resources:
    limits:
      cpus: '1.0'
      memory: 512m  # lowercase 'm'
Enter fullscreen mode Exit fullscreen mode

Container started instantly.

The problem was uppercase M vs lowercase m. Docker Compose silently interpreted 512M as zero memory, so the container killed itself immediately.

Docker Compose is case sensitive for memory units. Use lowercase m or you get zero memory allocation. Also learned to check the actual resource allocation before assuming out of memory means system memory. Container might have been allocated nothing.

Still annoyed I wasted 2 hours on a single character tho.

Top comments (0)