English 中文(简体)
bash 打字的cker子“被否认”
原标题:docker entrypoint running bash script gets "permission denied"

I m trying to dockerize my node.js app. When the container is built I want it to run a git clone and then start the node server. Therefore I put these operations in a .sh script. And run the script as a single command in the ENTRYPOINT:

FROM ubuntu:14.04

RUN apt-get update && apt-get install -y build-essential libssl-dev gcc curl npm git

#install gcc 4.9
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt-get update
RUN apt-get install -y libstdc++-4.9-dev

#install newst nodejs
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ADD package.json /usr/src/app/
RUN npm install

ADD docker-entrypoint.sh /usr/src/app/

EXPOSE 8080

ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"] 

我的多克入境点就是这样:

git clone git@<repo>.git
git add remote upstream git@<upstream_repo>.git

/usr/bin/node server.js

After building this image and run:

docker run --env NODE_ENV=development -p 8080:8080 -t -i <image>

页: 1

docker: Error response from daemon: oci runtime error: exec: "/usr/src/app/docker-entrypoint.sh": permission denied.

直升机进入集装箱,并获准进入点。 具体如下:

-rw-r--r-- 1 root root 292 Aug 10 18:41 docker-entrypoint.sh

三个问题:

  1. 我的双脚本是否有错的yn子?

  2. How do I change the permission of a bash file before adding it into an image?

  3. 如何在入境点使用双管指挥系统而不使用双管套?

感谢。

最佳回答
  1. “被拒绝入境”阻止在所有上援引你的文字。 因此,唯一可能相关的辛迪加是第一行(“she”),该行应参照<代码>#!/usr/bin/env bash 或#!/bin/bash,或视您的目标档案系统配置情况,类似。

  2. Most likely the filesystem permissions not being set to allow execute. It s also possible that the shebang references something that isn t executable, but this is far less likely.

  3. 用于修复先前的问题。


简单阅读

docker: Error response from daemon: oci runtime error: exec: "/usr/src/app/docker-entrypoint.sh": permission denied.

......该字标有明显的可执行性。

RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"]

将在集装箱内解决这一问题。 另外,您可以确保多克文件中提及的地方拷贝可执行<>m>,然后使用COPY(明确记录为保留元数据)。

问题回答

一份可执行的文件需要获得执行许可才能执行。

在您的机器中,你正在树立cker人形象(不是在cker人形象本身之内)试图操作:

ls -la path/to/directory

2. 贵方可执行的产出第一栏(此处为 do-入境点)。

-rwxrwxr-x

否则:

chmod +x docker-entrypoint.sh

然后再造你的cker形象。

多克人使用自己的档案系统,但复制了来源名录上的所有(包括许可)。

I faced same issue & it resolved by

ENTRYPOINT ["sh", "/docker-entrypoint.sh"]

对原始问题中的Dockerfile,应当:

ENTRYPOINT ["sh", "/usr/src/app/docker-entrypoint.sh"]

问题在于原始档案未经批准。

www.un.org/Depts/DGACM/index_spanish.htm 检查原始档案须经许可。

缩略语

如果结果-rw-r-r-r- ,

run
chmod +x docker-entrypoint.sh

之前,有人 build!

Remove Dot [.]

最后,我花了3个多小时的时间,我刚刚尝试把问题从尾去掉了dot

问题

docker run  -p 3000:80 --rm --name test-con test-app .

/usr/ local/bin/docker-enterpoint.sh: 8: exec: : Permission granted

仅从你指挥线结束起删除<>dot:

docker run  -p 3000:80 --rm --name test-con test-app 

文档的赠款执行权:docker-enterpoint.sh

sudo chmod 775 docker-entrypoint.sh

这是一种微乎其微的争.,但我收到的错误信息被拒,我发出这种错误信息,企图予以解决。 (例如)

我认为,我只字不提我使用的任何手法。

FROM node:14.9.0

我是,在我当地暴露/连接港口:

docker run -p 80:80 [name] . # this is wrong!

说明

/usr/local/bin/docker-entrypoint.sh: 8: exec: .: Permission denied

但是,最终你甚至有 do,在记录另一个项目时,由于错误的摄取而增加了它。 http://www.ohchr.org。

docker run -p 80:80 [name]

I like Docker a lot but it s sad it has so many gotchas like this and not always very clear error messages...

我也面临同样的问题。 这为我工作。

COPY ./entrypoint.sh /entrypoint
RUN sed -i  s/
//  /entrypoint
RUN chmod +x /entrypoint

ENTRYPOINT ["/entrypoint"]

如果你做not使用DockerFile,你可以简单地增加许可,作为篮子的指挥线理由:

docker run -t <image>  /bin/bash -c "chmod +x /usr/src/app/docker-entrypoint.sh; /usr/src/app/docker-entrypoint.sh"

这是我在回答前两年提出的老问题,我将把为我行道做什么。

在我的工作名录中,我有两个档案:Dockerfile &准备金。 sh

Dockerfile:

FROM centos:6.8

# put the script in the /root directory of the container
COPY provision.sh /root

# execute the script inside the container
RUN /root/provision.sh

EXPOSE 80

# Default command
CMD ["/bin/bash"]

规定:

#!/usr/bin/env bash

yum upgrade

我能够把集装箱外的档案作为可执行的<条码>chmod 700规定,从而对码头集装箱的档案加以起诉。 sh 然后运行docker Building .

If you still get Permission denied errors when you try to run your script in the docker s entrypoint, just try DO NOT use the shell form of the entrypoint:

Instead of: ENTRYPOINT ./bin/watcher write ENTRYPOINT ["./bin/watcher"]:

https://docs.docker.com/engine/vis/builder/#enter

“enterography

我有4个我的q笑 do图像,这是原因。 拆除了所有“灯”;安装了新的图像。

docker images -a | grep "mysql" | awk  {print $3}  | xargs docker rmi -f

就我而言,在Dockerfile中,server.js的道路是不正确的,当我们向/code>提供适当的途径时,你可能不会面对这一问题。 建造工作已经成功。 刚从编造目录上检查

RUN mkdir -p /home/app
COPY . /home/app
CMD ["node", "/home/app/index.js"]

My previous version was CMD["node","index.js"]





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...