2017-10-09 34 views
13

我試圖設置我的elixir-phoenix應用程序與postgresql數據庫與Docker運行。這是我的Dockerfile樣子:Docker錯誤:standard_init_linux.go:185:exec用戶進程導致「沒有這樣的文件或目錄」

# ./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 

這是我的搬運工,compose.yml文件:

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" 

圖像成功建立,但是當我嘗試使用以下命令安裝依賴:

docker-compose run web mix do deps.get 

我得到這些錯誤:

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

PS:我發現了幾個答案,如this one,指出在bash文件開頭缺少一行,但它似乎不是我的情況。我沒有運行bash腳本,而我的錯誤出現在第185行,而不是179.

+0

http://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-endings/ – Righto

回答

8

就像你提到的,一個原因可能是bash文件在頂部缺少#!/bin/bash

另一個可能的原因可能是該文件是用Windows行結束符(CRLF)保存的。保存它與Unix行尾(LF),它會被發現。

+1

您節省了我的一天。我正在使用git config core.autocrlf = true(文件被保存在Windows行結尾(CRLF)),甚至沒有想到它可以干預泊塢窗。真的很感謝你 – vladkha

+1

拯救生命--http://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-endings/ – Righto

相關問題