Pi Zero Wireless: troubleshooting raspistill image capture errors in multi-container docker app

Hello gurus,
I’m attempting to run raspistill on a Pi Zero Wireless. I’ve had success without balena.io installed, however it’s far more useful to have it dockerized and here. :grinning:

I’m having pretty good luck on setup thus far. I have two services running with volumes created and mounted/shared (cool), one service that doesn’t do much yet (“motion-capturer”) and one that is managing raspistill processes via node.

Challenge: Separate from the Nodejs thing (which is working great on its own), if I login to the raspistill-manager host and run raspistill, I get a nice menu of things I can do. It’s there! However, if I run a capture command e.g. raspistill -o cam.jpg, I get this error:

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

I’m not quite sure where to continue with this one. For fleet config vars, I have:

RESIN_HOST_CONFIG_gpu_mem = 128
RESIN_HOST_CONFIG_start_x = 1

I’m not sure if this is being pulled into the single device yet or not.

docker-compose.yml:

version: '2'
volumes:
    # This RAM drive is for raspicam to place a constant stream of images while not
    # burning out MicroSD card, pending motion detection and move to image-ready.
    image-temp:
        driver_opts:
            type: tmpfs
            device: tmpfs
            # 128MB (in bytes)
            size: 134217728
    # Images are stored here when motion is detected, ready for upload when possible.
    image-ready:
services:
    raspistill-manager:
        build: ./raspistill-manager
        # doesn't seem to make a difference beyond devices, should* remove?:
        privileged: true
        volumes:
            - 'image-temp:/image-temp'
        devices:
            - /dev/dri:/dev/dri #optional temporary for reference
            # next one required by raspistill:
            - /dev/vchiq:/dev/vchiq #optional KEEP THIS ONE OTHERWISE NO RUN RASPISTILL
            - /dev/video10:/dev/video10 #optional temporary for reference
            - /dev/video11:/dev/video11 #optional temporary for reference
            - /dev/video12:/dev/video12 #optional temporary for reference
    motion-capturer:
        build: ./motion-capturer
        volumes:
            - 'image-temp:/image-temp'
            - 'image-ready:/image-ready'

raspistill-manager Dockerfile.template:

###################################
# First Stage: Compile TypeScript #
###################################

# Thanks: https://stackoverflow.com/questions/60916271/how-do-i-run-typescript-tsc-before-copy-in-dockerfile-template/60917273#60917273
FROM balenalib/%%BALENA_MACHINE_NAME%%-node AS build

# Install needed packages to build raspicam Node dependencies.
RUN install_packages libraspberrypi-bin

WORKDIR /usr/src/app

# Install the Javascript dependencies, including all devDependencies.
COPY package.json .
RUN npm i

# Copy the rest of the application in and build it.
COPY . ./

# RUN npm build
RUN ./node_modules/typescript/bin/tsc -p ./tsconfig.json

# Clean up node_modules to not include dev dependencies.
RUN rm -rf ./node_modules
RUN JOBS=MAX npm i --production

##################################
# Second Stage: Prepare Dist App #
##################################

FROM balenalib/%%BALENA_MACHINE_NAME%%-node

# Defines our working directory in container
WORKDIR /usr/src/app

# Install packages
RUN install_packages libraspberrypi-bin

# Copy needed files in root to the working directory in the container
COPY --from=build /usr/src/app/dist dist
COPY --from=build /usr/src/app/node_modules dist/node_modules
COPY package.json package.json

# server.js will run when container starts up on the device
CMD ["npm", "run", "serve"]

Any thoughts on how I should proceed? Thanks for taking a look in advance!

EDIT: Do I need to pass these in via environment yml option by chance?

EDIT: I’m catching up on this related looking post.

Hah! Everything was working great. The error was because there can only be one raspistill client running at the same time. My brain was just diffused after a long day of working other tasks.

Have a very awesome day.

I’m glad you solved it. Have a good day!