E
E
Evgeny Zalivadny2021-07-07 22:30:04
Docker
Evgeny Zalivadny, 2021-07-07 22:30:04

How to run docker services so that the rights to volumes belong to the host user?

This tutorial https://strapi.io/documentation/developer-docs/lat... uses docker-compose to get two services up and running: MySQL and Strapi.

The problem is that even if you create the app and data folders before launching docker-compose up, then inside the rights to files and folders will be overwritten.
The app folder will become owned by the root user.
The data folder is 999, and the Owner of the data folder itself will also change.

Accordingly, the question is: how to correctly and without crutches make everything in the docker service folder belong to the current host user, i.e. who is running the command? This is necessary so that you can edit files on the disk from your user without entering the container. Now I can't edit the files.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-07-07
@sergiks

In the Dockerfile itself , they explicitly have a user:
RUN mkdir /srv/app && chown 1000:1000 -R /srv/app
Copy this Dockerfile to yourself and change 1000 in it to the uid of the current host user. Specify this modified Dockerfile in docker-compose.yml:

services:
  strapi:
    build:
      context: .
      dockerfile: Dockerfile-edited

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question