【问题标题】:Docker error: standard_init_linux.go:185: exec user process caused "no such file or directory"Docker 错误:standard_init_linux.go:185: exec 用户进程导致“没有这样的文件或目录”
【发布时间】:2017-10-09 17:24:08
【问题描述】:

我正在尝试将我的 elixir-phoenix 应用程序与 postgresql 数据库一起设置为与 Docker 一起运行。这就是我的 Dockerfile 的样子:

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

这是我的 docker-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 行。

【问题讨论】:

标签: postgresql docker elixir docker-compose phoenix-framework


【解决方案1】:

正如您所提到的,一个原因可能是 bash 文件在顶部缺少 #!/bin/bash

另一个可能的原因可能是文件以 Windows 行结尾 (CRLF) 保存。用 Unix 换行符 (LF) 保存它,它就会被找到。

【讨论】:

  • 你拯救了我的一天。我正在使用 git config core.autocrlf=true (文件以 Windows 行结尾(CRLF)保存),甚至不认为它可以干预 docker。真的谢谢你
  • 我本来想说你也拯救了我的一天,但实际上,我在寻找这个答案时失去了一切:(
猜你喜欢
  • 2018-10-31
  • 2019-01-01
  • 2019-09-19
  • 2021-10-23
  • 1970-01-01
  • 1970-01-01
  • 2021-05-16
  • 2018-12-07
  • 2020-10-25
相关资源
最近更新 更多