Docker错误:standard_init_linux.go:185:exec用户进程导致“没有这样的文件或目录”
问题描述:
我试图设置我的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.
答
就像你提到的,一个原因可能是bash文件在顶部缺少#!/bin/bash
。
另一个可能的原因可能是该文件是用Windows行结束符(CRLF)保存的。保存它与Unix行尾(LF),它会被发现。
http://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-endings/ – Righto