Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chown: /var/www/html: Operation not permitted #74

Open
adam-clarey opened this issue Sep 13, 2020 · 2 comments
Open

chown: /var/www/html: Operation not permitted #74

adam-clarey opened this issue Sep 13, 2020 · 2 comments

Comments

@adam-clarey
Copy link

adam-clarey commented Sep 13, 2020

Problem:
I'm trying to replicate the docker4drupal infrastructure in a bitbucket pipeline to run the automated tests. I cant just use the php image (which does work and can run unit tests, but not browser based tests) as the primary image in the pipeline, so instead i'm running 'docker-compose up' within a docker container (see pipeline script).

Pretty much all the containers startup as expected (chrome, memchached etc), however php and nginx images do not startup. Running 'docker-compose ps' shows both of those containers with status 'Exit 1'.

I've tried everything I can think of regarding permissions, such as setting 'user' : 'root' in the php container, changing the permissions on the host container etc. I've run out of ideas so hoping someone can point me in the right direction.

To make things simpler to debug, I have removed all containers from docker-compose.yml leaving only the php container.

Screenshot 2020-09-13 at 09 59 04

docker-compose.yml

version: "3"

services:

  php:
    image: wodby/drupal-php:latest
    container_name: "${PROJECT_NAME}_php"
    user: root
    command: 'php-fpm -R'
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      PHP_FPM_USER: root
      PHP_FPM_GROUP: root

    volumes:
    - ./:/var/www/html
    - ./files:/mnt/files

bitbucket-pipeline.yml

pipelines:
  default:
    - step:
        services:
          - docker
        caches:
          - docker
        script:
          - echo `uname -s`-`uname -m`
          - curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
          - chmod +x /usr/local/bin/docker-compose
#          - chown -R 1000:1000 ../build
#          - chown -R 82:82 ../build
          - whoami
          - pwd
          - ls -al
          - ls -al ../
          - docker-compose up -d 
          - docker-compose ps
          - docker logs iYieldValuation_php
          - docker exec iYieldValuation_php composer install --no-interaction
          - docker exec iYieldValuation_php vendor/bin/phpunit web/core/modules/action
          - docker-compose down

@jowan
Copy link

jowan commented Apr 22, 2021

Hi - did you solve this ?
It is definitely to do with the shared volume ./:/var/www/html
if you remove those, it will work. But that doesn't really help.
I too have changed perms and users and umask et'al and no joy.
I also do have this working on another platform and can't figure out what the difference is.
My set up is similar - testing in BB Pipelines, but Ubuntu is my local dev (works fine).

@jowan
Copy link

jowan commented Apr 22, 2021

I think this is relevant - BitBucket does some funky stuff, as explained here.

https://community.atlassian.com/t5/Bitbucket-questions/How-to-chown-or-write-to-my-pipeline-container-for-testing/qaq-p/1058917

So - workaround, in PHP/Nginx is - nest one folder deeper

volumes:
    - ./:/var/www/html/SUBFOLDER

And make sure nginx uses that for its server root using the correct env var

NGINX_SERVER_ROOT=/var/www/html/SUBFOLDER

Even though on a desktop you can mount to the /var/www/html from your project source, in BitBucket Pipelines, this can not be done, well it can - but you can't then chmod! It has to do with userns (name spaces) but I am unclear how to get round it.

It seems like any call to $ chmod on a file from within a container, that is also within a shared volume - will not work !

This is not to do with Wodby images :) and suggest closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants