postgresql - Docker 错误 : standard_init_linux. go:185: exec 用户进程导致 "no such file or directory"

标签 postgresql docker elixir docker-compose phoenix-framework

我正在尝试将我的 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 行。

最佳答案

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

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

关于postgresql - Docker 错误 : standard_init_linux. go:185: exec 用户进程导致 "no such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46651861/

相关文章:

amazon-web-services - 面临将 EFS 卷附加到 Kubernetes pod 的问题

python - Docker:主管无法启动uwsgi

macos - brew链接错误libpng和libtiff

Elixir 从直播中获取元数据

elixir - 在 Elixir 中进行模式匹配之前检查数据类型

sql - 为什么还要在 Golang 中使用 *DB.exec() 或准备好的语句?

postgresql - 运算符不存在 : json @> unknown

sql - 从表中获取唯一记录,避免基于两个键列的所有重复项

sql - PostgreSQL 上的计数估计

maven - 如何将带有密码的maven settings.xml放在源代码管理中