ホーム > Docker > How to Fix "Killed" Error Due to Insufficient Swap Memory in Docker
Docker

How to Fix "Killed" Error Due to Insufficient Swap Memory in Docker

Thank you for your continued support.
This article contains advertisements that help fund our operations.

A guide to solving the issue where a Docker container is killed due to insufficient Swap Memory.

Background

As the number of Gatsby.js articles increased, running gatsby develop started to result in the build process being abruptly stopped with a killed message. No other logs were shown.

After looking into it, I found that a sudden "killed" message usually indicates insufficient memory. So, I decided to increase the Swap Memory allocation for Docker.

Error Message

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Aborted
success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 19.066s - 55/55 2.88/s
warn Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
⠼ Building development bundle
Killed

How to Check Swap Memory

Inside the container, run:

free -h

This will show the current memory status.

How to Increase Swap Memory

Since I was using Docker Desktop, I simply went to:

Settings (gear icon) → Resources

and adjusted the memory slider shown there.

docker memory

It was surprisingly easy—if only I had known earlier!

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!