Docker compose error (mem_limit)

Docker

Senario

When you try to run container with ./docker-compose.yml file, you will get below error message.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose/cli/main.py", line 71, in main
File "compose/cli/main.py", line 121, in perform_command
File "compose/cli/command.py", line 37, in project_from_options
File "compose/cli/command.py", line 91, in get_project
File "compose/config/config.py", line 375, in load
File "compose/config/config.py", line 506, in process_config_file
File "compose/config/config.py", line 497, in interpolate_config_section
File "compose/config/interpolation.py", line 44, in interpolate_environment_variables
File "compose/config/interpolation.py", line 44, in <genexpr>
File "compose/config/interpolation.py", line 39, in process_item
File "compose/config/interpolation.py", line 39, in <genexpr>
File "compose/config/interpolation.py", line 54, in interpolate_value
File "compose/config/interpolation.py", line 74, in recursive_interpolate
File "compose/config/interpolation.py", line 74, in <genexpr>
File "compose/config/interpolation.py", line 70, in recursive_interpolate
File "compose/config/interpolation.py", line 184, in convert
File "compose/config/interpolation.py", line 141, in to_int
ValueError: invalid literal for int() with base 0: '512m'
Failed to execute script docker-compose

Summary

The value of mem_limit no more supported with recent docker-compose (1.18.0)

Hot-fix

Just edit your docker-compose.yml and remove mem_limit lines. The best soloution should be replace as RESOURCES.

1
2
3
4
5
6
7
8
# backup your file
cp -a docker-compose.yml docker-compose.yml.bak

# trim mem_limit
cat docker-compose.yml.bak |grep -v "mem_limit" > docker-compose.yml

# then run again
docker-compose up

Reference

https://support.zabbix.com/browse/ZBX-13224
https://docs.docker.com/compose/compose-file/#resources