简体   繁体   中英

Docker-compose is mounting volumes with 1001:1001 USER:GROUP

On a remote VPS, I am mounting volumes thanks to this docker-compose:

version:  '3.3'

services:
  webapp:
    build:
      context: ./docker/webapp/
    volumes:
      - '${RELEASES_DIRECTORY}:/var/apps/site.org/releases'
      - '${REPO_DIRECTORY}:/var/apps/site.org/repo'
      - '${SHARED_DIRECTORY}:/var/apps/site.org/shared'
      - './docker/webapp/over.php.ini:/usr/local/etc/php/conf.d/over.php.ini'
    environment:
      - APP_ENV=prod
      - APP_DEBUG=0
      - APP_DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${MYSQL_HOST}/${MYSQL_DATABASE}
      - MYSQL_SERVER_VERSION=${MYSQL_SERVER_VERSION}
      - MAILER_DSN=sendgrid+api://${SENDGRID_API_KEY}@default
    working_dir: /var/apps/site.org
    command: php-fpm

Here is the relative Dockerfile:

FROM php:7.4-fpm-alpine

# OS DEPENDENCIES
RUN apk update
RUN apk add --no-cache bash git curl libmcrypt libmcrypt-dev openssh-client icu-dev
RUN apk add --no-cache libxml2-dev freetype-dev libpng-dev libjpeg-turbo-dev zip libzip-dev g++ make autoconf
RUN apk add --no-cache php7-mysqli
RUN docker-php-source extract
RUN docker-php-source delete
RUN docker-php-ext-install soap intl zip
RUN docker-php-ext-install opcache
RUN docker-php-ext-install mysqli pdo pdo_mysql

#Creation APP Directory
RUN mkdir -p /var/apps
RUN mkdir -p /var/apps/site

# COMPOSER INSTALLATION
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# EXORT COMPOSER GLOBAL PATH
RUN echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
RUN source ~/.bashrc

# INSTALL NODE & NPM
RUN apk add --update nodejs npm
RUN npm config set production
RUN export NODE_ENV=production

On my local machine, when I go inside the docker throung docker exec , every mapped directories are root:root but on my remote host (VPS), they are 1001:1001 and I donèt get where does it can come from?

I tried to re-install docker and docker-compose but I have the same behaviour. The VPS runs

  • Unbuntu 18.04
  • Docker version 19.03.8, build afacb8b7f0
  • docker-compose version 1.25.5, build 8a1c60f6

When you bind host files to a docker container (bind mounting), the file's permissions aren't changed.

Your VPS probably has those files owned by a user whose uid is 1001, while the same files on your system are owned by root.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM