Docker / lxc set memory limit invalid argument

When trying to resize a docker or LXC container by changing the value in /sys/fs/cgroup/memory/docker//memory.limit_in_bytes if you come across the error

write error: Invalid argument

When going above a certain amount (for me it was 1024MB).

It’s most likely due to your memory limit being higher than your memory + swap limit. You need to edit the file memory.memsw.limit_in_bytes and increase it’s value.