18

I'm trying to set my elixir-phoenix app with postgresql database to run with Docker. This is what my Dockerfile looks like:

# ./Dockerfile

# Starting from the official Elixir 1.5.2 image:
# https://hub.docker.com/_/elixir/
FROM elixir:1.5.2

ENV DEBIAN_FRONTEND=noninteractive

# Install hex
RUN mix local.hex

# Install rebar
RUN mix local.rebar

# Install the Phoenix framework itself
RUN mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

# Install NodeJS 6.x and the NPM
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y -q nodejs

# Set /lib as workdir
WORKDIR /lib

And this is my docker-compose.yml file:

web:
  build: .
  dockerfile: Dockerfile 
  env_file: .env 
  command: mix phx.server # Start the server if no other command is specified
  environment:
    - MIX_ENV=dev
    - PORT=4000
    - PG_HOST=postgres
    - PG_USERNAME=postgres
  volumes:
    - .:/lib 
  ports:
    - "4000:4000"
  links:
    - postgres

test:
  image: phoenixbootstrap_web
  env_file: .env
  command: mix test
  environment:
    - MIX_ENV=test 
    - PORT=4001
    - PG_HOST=postgres
    - PG_USERNAME=postgres
  volumes_from:
    - web
  links:
    - postgres

postgres:
  image: postgres:10.0
  ports:
    - "5432"

The image builds successfully, but when I try to install the dependencies with the following command:

docker-compose run web mix do deps.get

I get these Error:

standard_init_linux.go:185: exec user process caused "no such file or directory"

PS: I found a couple of answers like this one, pointing out a missing line at the beginning of a bash file but it doesn't seem to be my case. I run no bash script and my error appears in line 185, not 179.

ntonnelier
  • 1,539
  • 3
  • 23
  • 49

1 Answers1

17

Like you mentioned, one cause could be that the bash file is missing #!/bin/bash at the top.

Another possible reason could be if the file is saved with Windows line endings (CRLF). Save it with Unix line endings (LF) and it will be found.

Ryan Allen
  • 5,414
  • 4
  • 26
  • 33
  • 3
    You saved my day. I was using git config core.autocrlf=true (files were saved with Windows line endings (CRLF)) and didn't even think that it could intervene with docker. Really thank you – vladkha Jan 08 '18 at 13:41
  • 2
    Life saver -http://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-endings/ – Righto Jan 11 '18 at 10:38
  • I was going to say that you saved my day too but actually, I lost it all looking for this answer :( – Defozo May 15 '18 at 13:24