Volume Permission
renerlemes
PROOP

a year ago

I have a container that I need to attach a volume to. However, when I start the container, I always get a message that it is not possible to create the directory.

mkdir: cannot create directory ‘/opt/emqx/data/configs’: Permission denied

I am following the documentation on the website https://docs.emqx.com/en/emqx/latest/faq/deployment.html

Is there any way to create the volume and have the necessary permissions?

$10 Bounty

8 Replies

a year ago

Where is your volume mounting?


renerlemes
PROOP

a year ago

I sent it as an attachment

Attachments


a year ago

You could try setting a start command that sets your permissions correctly, something like this;

sh -c "chown -R 1000:1000 /opt/emqx/data && exec /usr/bin/docker-entrypoint.sh emqx foreground"


iiroan

You could try setting a start command that sets your permissions correctly, something like this; `sh -c "chown -R 1000:1000 /opt/emqx/data && exec /usr/bin/docker-entrypoint.sh emqx foreground"`

renerlemes
PROOP

a year ago

Another error message

Attachments


renerlemes

Another error message

a year ago

Looks like this is the exact error you encountered

https://docs.emqx.com/en/emqx/latest/faq/deployment.html#failed-to-start-emqx-with-docker-log-prompts-permission-denied

This kind of problem is really annoying to deal with on railway, you would have to either ssh into and fix it manually (if possible)

or change the Dockerfile or entrypoint script.


iiroan

Looks like this is the exact error you encountered <https://docs.emqx.com/en/emqx/latest/faq/deployment.html#failed-to-start-emqx-with-docker-log-prompts-permission-denied> This kind of problem is really annoying to deal with on railway, you would have to either ssh into and fix it manually (if possible) or change the Dockerfile or entrypoint script.

renerlemes
PROOP

a year ago

I also tried this solution, I even put the link in the first comment. I tried changing the dockerfile to use named volume, and it also gave the same problem.


renerlemes

I also tried this solution, I even put the link in the first comment. I tried changing the dockerfile to use named volume, and it also gave the same problem.

a year ago

If you can change the dockerfile, you can also set the permissions correctly.

# Switch to root to modify permissions

USER root

# Create the directories and set proper ownership

RUN mkdir -p /opt/emqx/data /opt/emqx/log && \

chown -R emqx:emqx /opt/emqx/data /opt/emqx/log && \

chmod -R 755 /opt/emqx/data /opt/emqx/log

# Switch back to emqx user

USER emqx

adjust it if needed


renerlemes
PROOP

a year ago

Here in Railway you can't use chown, it gives an error message, but I tried the following way in the dockerfile and the container started, but the data is not persisted

version: "3.9"

services:

emqx:

image: emqx/emqx-enterprise:5.9.0

container_name: emqx

user: root

volumes:

- emqx_data:/opt/emqx/data

- emqx_log:/opt/emqx/log

ports:

- "1883:1883"

- "8883:8883"

- "8081:8081"

- "8083:8083"

- "18083:18083"

volumes:

emqx_data:

emqx_log:


Welcome!

Sign in to your Railway account to join the conversation.

Loading...