Release error: Failed to create cookie file '/.erlang.cookie'

Hi, this is the first time I migrated the release system for a distributed app from Distillery to Elixir releases.

I’m building a docker image containing the release but when I launch it I’m getting this error:

=ERROR REPORT==== 16-Aug-2023::14:04:26.370926 ===
Failed to create cookie file '/.erlang.cookie': eacces
=CRASH REPORT==== 16-Aug-2023::14:04:26.377384 ===

I tried to create a writable /.erlang.cookie file with some contents but it didn’t work.

Creating a release in the past with just Elixir releases has not been a problem, but this time I don’t know how to fix this error.

Can you show us your Docker file? The error you’re getting is basically “access denied, can’t create file” basically, btw.

Sure, but I wonder if the cookie path can be somehow changed in vm.args.

FROM alpine:latest

RUN mkdir -p /app && chown -R nobody: /app
# By doing this the app doesn't boot, it complains about the owner of the file
# RUN touch /.erlang.cookie && chmod 600 /.erlang.cookie

WORKDIR /app
USER nobody

COPY --chown=nobody:nobody _build/prod/rel/my_app .

ENV REPLACE_OS_VARS=true
ENV HTTP_PORT=4291 BEAM_PORT=14291 ERL_EPMD_PORT=24291

EXPOSE $HTTP_PORT $BEAM_PORT $ERL_EPMD_PORT
ENTRYPOINT ["/app/bin/my_app"]

Not sure about the file – you can probably create it outside of Docker and jitsu mount it as a volume?

Or, according to https://github.com/processone/docker-ejabberd/tree/master/ecs#clustering-example you can also just set the ERLANG_COOKIE environment variable (inside the container I mean).

Isn’t it RELEASE_COOKIE cf mix release — Mix v1.15.4 ?

or even set it in the Mix.Project.project releases I believe

Could be, I was looking at the Erlang config.

It seems that the Erlang restringes the location of the erlang.cookie file, it will be created in the $HOME directory.

What happened is that $HOME was set to /

Once I changed it in the Dockerfile, the file could be created and the app booted!

ENV HOME=/app

Thanks you all guys!