5

I have a laravel project. And this is my docker-compose.yml file.

nginx:
    build: ./nginx/
    ports:
        - 90002:80
    links:
        - php
    volumes_from:
        - app

php:
    build: ./php/
    expose:
        - 9000
    links:
        - mysql
    volumes_from:
        - app

composer:
    image: composer/composer
    volumes_from:
        - php
    working_dir: /var/www/html

app:
    image: php:7.0-fpm
    volumes:
        - ./test-api:/var/www/html
    command: "true"

mysql:
    image: mysql:latest
    volumes_from:
        - data
    environment:
        MYSQL_ROOT_PASSWORD: test
        MYSQL_DATABASE: user
        MYSQL_USER: uesr
        MYSQL_PASSWORD: test

data:
    image: mysql:latest
    volumes:
        - /var/lib/mysql
    command: "true"

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
        - 90003:80
    links:
        - mysql
    environment:
        PMA_HOST: mysql

And I run this command.

$ docker-compose build --no-cache
$ docker-compose up -d
$ docker-compose run --rm composer install # error

I got error message

[RuntimeException]
/var/www/html/vendor does not exist and could not be created.

I tried on my Mac, it's work. But ssh to my service, use the same method, it's not work. Thanks your help.

lighter
  • 2,808
  • 3
  • 40
  • 59

2 Answers2

0

If you're testing it on Windows, there could be a problem with syncing the files.

If that's the case, you can try to exclude vendor dir, see: Add a volume to Docker, but exclude a sub-folder

Similar problem: Problem when I execute npm install on docker

kenorb
  • 155,785
  • 88
  • 678
  • 743
0

Since it doesn't work on Windows, but it does on macOS, try to:

  • Double check the permissions of /var/www/html and vendor folder on your host as you're potentially sharing this folder from NTFS file-system which doesn't support Linux permissions,
  • Check whether files or folder is locked by some running process (e.g. shell or IDE editor).

    For example, using Process Explorer, select Find Handle or DLL from Find menu and type folder name.

    I had similar problem which I've described here.

kenorb
  • 155,785
  • 88
  • 678
  • 743