Ishi Inanis
Ishi Inanis

Reputation: 21

When running docker-compose remotely, an error occurs with mounting volumes

I am trying to run a project on docker-compose via a remote server. Everything works, but as soon as I add the item about mounting the volume, it gives an error:

Error response from daemon: invalid mount config for type "bind": invalid mount path: 'C:/Users/user/Projects/my-raspberry-test' mount path must be absolute

To run I use tools from PhpStorm.

The docker-compose.yml file itself looks like this:

version: "3"

services:
  php:
    image: php:cli
    volumes:
      - ./:/var/www/html/
    working_dir: /var/www/html/
    ports:
      - 80:80
    command: php -S 0.0.0.0:80

I checked by ssh:

Also checked docker remote run using phpstorm and file:

FROM php:cli
COPY . /var/www/html/
WORKDIR /var/www/html/
CMD php -S 0.0.0.0:80

It didn’t give an error and it worked.

OS on devices:

Without mounting the volume in docker-compose, everything starts. Maybe someone faced a similar problem? php for an example.

Upvotes: 1

Views: 1000

Answers (1)

Ishi Inanis
Ishi Inanis

Reputation: 21

The path must be absolute for the remote host and the project data itself must be loaded there. That is, you need to upload the project to a remote host.

I corrected everything like this:

volumes:
  - /home/peter-alexeev/my-test:/var/www/html/

Upvotes: 1

Related Questions