【问题标题】:dockerfile cant find entrypoint.shdockerfile 找不到 entrypoint.sh
【发布时间】:2020-05-22 15:01:39
【问题描述】:

我的文件系统:

  • Dockerfile
  • entrypoint.sh
  • package.json
  • /shared_volume/

Dockerfile

FROM node:8


# Create and define the node_modules's cache directory.
RUN mkdir /usr/src/cache
WORKDIR /usr/src/cache

COPY . .
RUN npm install

# Create and define the application's working directory.
RUN mkdir /usr/src/app
WORKDIR /usr/src/app

# entrypoint to copy the node_modules and root files into /usr/src/app, to be shared with my local volume.
ENTRYPOINT ["/usr/src/cache/entrypoint.sh"]

package.json

{
  "name": "test1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "echo hello world start"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "rimraf": "^3.0.1"
  }
}

entrypoint.sh

#!/bin/bash
cp -r /usr/src/cache/. /usr/src/app/.

命令行 - bash 脚本

如果我运行此代码(注意:使用带有 cmder 的 windows 10,因此 %cd% 不是 pwd):

docker run -it --rm -v %cd%/shared_volume:/app --privileged shared-volume-example bash

错误

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

如果我去掉对入口点的引用,那么代码就可以工作,那么入口点是怎么回事?

任何建议。 谢谢

【问题讨论】:

  • 你的基础镜像是否包含/bin/bash?许多轻量级图像(尤其是基于 Alpine 的图像)没有;但是,如果您将自己限制在 POSIX shell 语言(您的脚本看起来不错),那么将 shebang 行更改为 #!/bin/sh 可能会有所帮助。还要检查脚本是否可执行。
  • 谢谢。是的,试过了。同样的问题。只是想知道 - from: node 是否根本不包含任何 bash?

标签: docker dockerfile docker-entrypoint


【解决方案1】:

好的,其他人发布了有关行尾的答案。我使用 atom line-ending-selector 并将其设置为 LF 替换,然后重新保存文件,现在它可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-15
    • 2021-01-17
    • 2017-09-14
    • 2021-11-23
    • 2015-08-19
    • 1970-01-01
    • 2021-01-09
    相关资源
    最近更新 更多