添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I’m taking the Docker course.

In the docker compose section the backend does not start when using the docker-compose up
command.

I get the following error in the console log
backend_1 | /usr/local/bin/docker-entrypoint.sh: exec: line 8: ./docker-entrypoint.sh: Permission denied

Anyone know how to fix this?

After some more googling I discovered that I had to set the file permissions of the docker-entrypoint.sh file on my filesystem not the container’s file system.

It seems the file permissions carry over to the container file system.

initially when I use the command for docker-compose up, when it tries to run the mongo image, it said, the port 27017 already in use
This I overcome, by running killing the process ID which was listening on the port 27017
Used the below command(Note I am running on Ubuntu Linux)
sudo kill sudo lsof -t -i:27017

After I solve the above problem, I got the error ‘Permission denied’ which I resolved using the solution you have provided here.

Thanks,
Pothirajan

Jay-R, I really appreciate you posting this! I can’t imagine how long it would have taken me to come up with this approach, thank you :slight_smile:

Hi Mosh, can you explain why this change was necessary, and how it worked? (I’m guessing it could be illuminating to know how the original code was able to work on your machine but not ours).
Also, do these exercises exist somewhere on github? I could not find it among codewithmosh repos. I was hoping to find a discussion or fix for this in a repo.
thanks,

This seems to be caused by the fact that all of the files are owned by root within the image, despite having USER app before the COPY .

I fixed this by adding --chmod=app:app to the COPY commands in the backend/Dockerfile and rebuilding the image.

WORKDIR /app
COPY --chown=app:app package*.json ./
RUN npm install
COPY --chown=app:app . . 

According to the docker COPY documentation:

All new files and directories are created with a UID and GID of 0, unless the optional --chown flag specifies a given username, groupname, or UID/GID combination to request specific ownership of the copied content.