Signal trapping in containers with enabled initsystem

Good day,

I’m having a problem with a fairly simple setup, our containers do not receive any kind of SIGTERM signal in their scripts. I have tried it with the following simple script:

#!/bin/bash
terminate() {
trap - 15
echo “SIGTERM”
}
trap terminate 15
echo “Idling now…”
while :; do sleep 1; done

I’m setting

ENV INITSYSTEM on

in the dockerfile as well as

CMD /sonah/src/test.sh

to start the script.

When hitting stop in the resin dashboard the container does NOT print SIGTERM.

Hi, this is a known issue. I will ping our base images maintainer for more information on this.

Do you also happen to overwrite the ENTRYPOINT in your Dockerfile?

No, we don’t use an ENTRYPOINT.
Currently this is how our own base images look:

FROM resin/raspberrypi3-python:3.6
ENV INITSYSTEM on

####################
###  Initialize  ###
####################
RUN [ "cross-build-start" ]

# Redacted section, but includes ONLY commands like:
# RUN mkdir <directory>
# COPY <pathonlocal> <pathondevice>
# RUN chmod +x <pathondevice>/<filename>.sh && <pathondevice>/<filename>.sh
# RUN rm -rf <pathondevice>

RUN [ "cross-build-end" ]

We then use this base image in our image like so:

FROM <redacted>
ENV INITSYSTEM on

# Redacted section, but includes ONLY commands like:
# RUN mkdir <directory>
# RUN mkdir <directory> <directory2> ...
# COPY <pathonlocal> <pathondevice>
# RUN chmod +x <pathondevice>/<filename>.sh && <pathondevice>/<filename>.sh
# RUN rm <pathondevice>

RUN chmod +x /sonah/src/test.sh
CMD /sonah/src/test.sh

Greetings, Tarek

Hi Tarek,

I got an update from our base images maintainer that we are working on releasing a new set of base images, which should be ready in a few days. We will send you an update on this once ready.

Thanks a lot,
Zahari

1 Like

Hi. We have an update on the new images. They are currently available at https://store.docker.com/community/images/balenalib/raspberrypi3-debian-python/tags . Please be aware of the following breaking changes:

  • udev defaults to off
  • INITSYSTEM has been completely removed, so applications that rely on systemd should install and set up systemd in their apps
  • removed automatic mounting of devtmpfs
  • dropped support for Debian Wheezy

Given the list of the changes I pointed to above, we strongly recommend testing the app in an isolated lab environemnt before rolling it to production devices.

1 Like