Windows 10 Docker : /usr/bin/env: 'php\r': No such file or directory

Salim Ben Aissa picture Salim Ben Aissa · Jun 11, 2018 · Viewed 13.5k times · Source

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

Answer

Maicon Carraro picture Maicon Carraro · Aug 13, 2018

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 :)