docker_container module always fails to update 'kernel_memory' attribute on a running container.

Hi,

I had some containers started with some attributes as variables, values of which i wish to control later. So consider this docker task:

`

  • name: Start container
    docker_container:
    name: “{{cname}}”
    image: “{{ image }}”
    state: started
    memory: “{{ mem }}”
    memory_reservation: “{{ memr }}”
    memory_swap: “{{ mems }}”
    kernel_memory: “{{ kernelMemory }}”
    `

I start some container with kernelMemory set to 0 and it works fine.
Now i wish to only update the kernel_memory, so i set kernelMemory: 1g or and re run the same playbook, but it fails with the following error:

fatal: [docker1]: FAILED! => {“changed”: false, “msg”: “Error updating container 06ad86660ce32f36267784c: 500 Server Error: Internal Server Error ("{"message":"Cannot update container 06ad86660ce32f36267784c: Can not update kernel memory to a running container, please stop it first."}")”}

Ok so it doesn’t allow that on running container, but shouldn’t there a provision in the module to restart/recreate the container if something has changed ? The module does that for other values. If this is supposed to happen like this, then i think at least the documentation needs to be updated as i am finding out this behavior only when i have a lot of containers already running, now i will have to kill them all first.

BR,
Ishan

Hi Ishan,

have you filed an issue on github for this? That increases the chance
that the docker_container maintainers find out about this :slight_smile:

Cheers,
Felix