Backend not starting in vidly app

Hi,

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?

2 Likes

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.

1 Like

Just change the backend command to this:

8 Likes

Thanks. I’ve been struggling with this. Setting file permission does not work for me, but this one does.

Thanks a lot :slight_smile:
That fixed the issue for me too !!

Thanks @Jay-R
I faced two problems

  1. 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

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

Thanks,
Pothirajan

Yes that worked!
Thanks

Thanks! That did the trick. :+1:

Anyone please send me this project zip file to my email or you can give me the link of repo. email id souma.hitech@gmail.com i can’t able to download the project

Thanks man.
Now working like a charm.

That didn’t do the trick for me. It gives me this new error instead:

Error: Cannot find module ‘/app/“sh”’

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,
Bill

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.