I have a docker-compose.yml file where i defined the images and the build for php. Its made for a Symfony application with php, nginx and postgresql with postgis:
version: '2'
services:
front:
image: nginx
ports:
- "81:80"
links:
- "engine:engine"
- "db:db"
volumes:
- ".:/home/docker:ro"
- "./docker/front/default.conf:/etc/nginx/conf.d/default.conf:ro"
engine:
build: ./docker/engine/
volumes:
- ".:/home/docker:rw"
- "./docker/engine/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
links:
- "db:db"
working_dir: "/home/docker"
db:
image: camptocamp/postgres:9.6
ports:
- "5433:5432"
environment:
- "POSTGRES_DB=pfe"
- "POSTGRES_PASSWORD=admin"
- "POSTGRES_USER=admin"
- "PGDATA=/var/lib/postgresql/data/pgdata"
Everything works fine on Ubuntu but when i tryied to run the same environement onw windows 10 i got an error.
docker-compose exec engine bin/console doctrine:schema:create
/usr/bin/env: 'php\r': No such file or directory
I figure out a way to solve based on this: https://stackoverflow.com/a/2613834/3257568
tr -d '\015' <DOS-file >UNIX-file
So, I did this:
$ docker exec -it <container> bash
$ cd bin
$ tr -d '\015' <console >console.new
$ mv console console.old
$ mv console.new console
It's now working :)
From the error message it seems you are facing issue related to EOL.
Try converting your scripts/files to UNIX formatted EOL.
You can use Sublime / Notepadd++ or any editor that supports this feature.
Or on unix platform you can try dos2unix.
Another possible fix for this kind of error is to add .gitattribues file to your project and set *.sh text eol=lf
(on any file extension that is run inside your docker containers). This way git defaults on Windows won't mess your .sh files. Caution: you need to get fresh git pull for this to work.
In my case the error was just running php script that did not have right permissions. So you chmod it beforehand or add php
at the beginning. Ex: php bin/console
Both problems could lead to the same error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With