Docker Container exited with code 137

Docker Container exited with code 137

January 18, 2018

applelinuxweb

 

When attempting to fire up a bunch of docker containers using docker-compose on a Mac, one of the containers was randomly exiting with the exit code 137. The message would look something like this:

container_name exited with code 137

My first reaction was to try to quickly run docker exec -it container-id /bin/bash and then take a look at the logs, but before I was quick enough to do that I decided to look into exit code 137.

As it turns out this code is commonly associated with Docker for Mac not having enough RAM allocated to it. More specifically the Linux OOM (out of memory) Killer, kicked in and terminated the process.

So it is an easy fix, go to the Docker Menu and select Preferences then the Advanced tab and increase the Memory.

Adjust docker memory to fix exited with code 137 error

My docker memory was set to 2.0 GB (perhaps the default), I increased it to 4.0 GB and problem solved.

You may also be able to get around this problem by setting the --memory limit when starting a container, or if you are using docker compose, you can do something like this in your docker-compose.yml file:

version: '3'
services:
  your-service-name:
    image: image-name:tag
    deploy:
      resources:
        limits:
          memory: 50M
        reservations:
          memory: 20M
Docker容器是通过Docker镜像创建的可运行实例。Docker容器是在Docker镜像的基础上建立一个可读写的容器层。镜像负责存储和分发应用程序,而容器负责运行应用程序。常用的Docker容器指令包括: - `docker container ls`:列出所有正在运行的容器的列表。 - `docker container ls -a`:列出所有容器的列表,包括正在运行的和已退出的容器。\[2\] 如果你想运行一个Docker容器,可以使用`docker run <IMAGE STRING>`命令,其中`<IMAGE STRING>`是你想要运行的镜像名称或标签。\[2\] 如果你想删除所有已退出的容器,可以使用以下命令: 1. 列出所有状态为exited的容器的ID:`docker container ls -f "status=exited" -q`\[1\] 2. 根据上述ID删除所有容器:`docker rm $(docker container ls -f "status=exited" -q)`\[1\] #### 引用[.reference_title] - *1* *2* [Docker Container介绍](https://blog.csdn.net/lt326030434/article/details/90384228)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [三、Docker相关概念-container](https://blog.csdn.net/qq_26707371/article/details/101467711)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值