# \[docker-compose\] service with "io.balena.features.kernel-modules=1" won't start

**URL:** <https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169>\
**Category:** Product support\
**Created:** [March 9, 2022, 12:42pm UTC](https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169 "2022-03-09T12:42:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndMaz](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@AndMaz](https://forums.balena.io/u/AndMaz)\
**Post date:** [March 9, 2022, 12:42pm UTC](https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169/1 "2022-03-09T12:42:11Z")

</div>

I have some strange issues with the “io.balena.features.kernel-modules=1” flag. After adding it to my docker-compose.yml the service won’t start and I don’t know what’s the issue. I added the flag as per this comment [Modprobe error when trying to enable i2c on rpi - #6 by CameronDiver](https://forums.balena.io/t/modprobe-error-when-trying-to-enable-i2c-on-rpi/4669/6) in order to solve the `modprobe` error.

```auto
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.10.83-v8/modules.dep.bin'
modprobe: FATAL: Module i2c-dev not found in directory /lib/modules/5.10.83-v8

```

I’ve logged to `host OS` via `ssh` and tried to run `balena logs <container-id>` but the logs are empty.

Running `balena events` also didn’t help. It shows that service tries to start and then that it stops + some mount volume info. However, I can’t find out what’s the exact issue. Does any one have any pointers about how to solve this issue?

Here’s my docker-compose:

```auto
version: '2.1'

services:
  test-service:
    build:
      context: ./docker/test
      dockerfile: Dockerfile.template
    image: test-service
    pid: 'host'
    container_name: test-service
    ports:
      - '5000:5000'
    restart: 'on-failure'
    privileged: true
    command: modprobe i2c-dev && python3 test
    # command: /bin/sh -c 'if ["$TEST_ENABLED" = "True"]; then python3 test; fi'
    volumes:
      - data:/app/data
    # labels:
    # io.balena.features.kernel-modules: '1'

volumes:
  data:

```

Another question. Any idea why the

```auto
command: /bin/sh -c 'if ["$TEST_ENABLED" = "True"]; then python3 test; fi'

```

doesn’t work? The var. is properly set (via `balena env add`) inside the container. Connecting to the service via `ssh` and running `printenv` I can see that `TEST_ENABLED=True`

Context:  
Device: RPi 4  
OS: balenaOS 2.94.4  
Supervisor: 12.11.36

---

<div class="post-metadata">

**Author:** ![richard.galvez](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@richard.galvez](https://forums.balena.io/u/richard.galvez)\
**Post date:** [March 9, 2022, 2:26pm UTC](https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169/2 "2022-03-09T14:26:28Z")

</div>

Hi-- wondering if you’ve looked into dt parameters yet? I think that’s the best practices way of enabling kernel modules such as i2c. You can do this under device configuration under the option of “Define DT parameters”. For example in your case you can add “12c=on”. You can read more here [firmware/README at master · raspberrypi/firmware · GitHub](https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README) hope it helps!

---

<div class="post-metadata">

**Author:** ![AndMaz](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@AndMaz](https://forums.balena.io/u/AndMaz)\
**Post date:** [March 9, 2022, 3:01pm UTC](https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169/3 "2022-03-09T15:01:26Z")

</div>

Thanks for the quick reply. No, I didn’t try that. I simply followed the docs [I2C and Other Interfaces - Balena Documentation](https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/#i2c) and then looked around the forum.

I’m gonna test your solution.

BTW any idea why this command doesn’t work on balena?

```auto
command: /bin/sh -c 'if ["$TEST_ENABLED" = "True"]; then python3 test; fi'

```

It fails on startup but works if I execute the command inside the container. Locally, on docker, it works just fine

---

<div class="post-metadata">

**Author:** ![rmorillo24](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/rmorillo24/32/10359_2.png) [@rmorillo24](https://forums.balena.io/u/rmorillo24)\
**Post date:** [April 19, 2022, 9:15am UTC](https://forums.balena.io/t/docker-compose-service-with-io-balena-features-kernel-modules-1-wont-start/354169/4 "2022-04-19T09:15:18Z")

</div>

Hi  
Did you finally test the solution?

Also, when you say that the command is failing, is it giving you an error? Or is it simply not retuning anything? If it´s not returning anything it may be because the variable hasn’t been set yet.
