I’m using the Packer tool to create an AWS AMI. I install Docker and a container as part of the provisioning. However, I also need to change the “ulimit -c unlimited” so that applications within a Docker container are able to produce a core file. We have scripts in the Docker container to trap signals and preserve the core file to a Docker volume.
From what I gather through experience, Packer logs into the AWS AMI in a single session and executes the provisioners in order. Since I’m working with Linux, I’m able to perform some “sudo” commands to modify the /etc/security/limits.conf file and remove any files in /etc/security/limits.d. This will allow changes in limits for the next login session, but not this current session.
I also need to install Docker and install the necessary containers. Since my current session has retained the limit values, the Docker installation will propagate the “soft” values to any container. In my case, the ulimit core is set to 0 for both hard and soft values. Docker will configure the containers with core limit of zero. Any application crashes within Docker will not produce core files.
Is there any way to configure the provisioners to change the ulimit settings for root access and session access? Alternatively, maybe there is a way to log off and log back on? Maybe as a last resort, reboot the AMI after one provisioner has changed the ulimits so that the next session login has the new values?