Docker-compose migrations are not working

Hello! I followed the tutorial and in the Migrating the Database section, I receive a “Could not fetch the movies!” message. I tried changing command: ./docker-entrypoint.sh to command: [“sh”, “docker-entrypoint.sh”] but the result is the same. I’m following the tutorial on Windows but I don’t think it matters because the image is Linux Alpine … Did anyone encountered the same problem?

2 Likes

Hi, i have the same problem, i was looking for more information in the forum and the only that I found was that about the entrypoint, but when I try to do that, the behavior is the same.
Can anyone help us?
Regards,
Oscar.

in Mac I got permission errors so I had to fix two things to get the DB working. After that the migration worked:

The Dockerfile of the backend:

  • had to copy the package.json file separately setting the ownership

FROM node:14.16.0-alpine3.13

RUN addgroup app && adduser -S -G app app

RUN mkdir -p /app && chown -R app:app /app

USER app

WORKDIR /app

COPY --chown=app:app package*.json ./

RUN npm install

COPY . .

EXPOSE 3001

CMD [“npm”, “start”]

Second - within docker-compose.yml: Use formatted version on calling docker-endpoint.sh in backend:

backend:
depends_on:
- db
build: ./backend
ports:
- 3001:3001
volumes:
- ./backend:/app
environment:
DB_URL: mongodb://db/vidly
command: [“sh”,“docker-entrypoint.sh”]

4 Likes

Thank you so much, Vermin. I lost hours trying to work around this. I am getting a new error now but at least the app seems to be working now.

./docker-entrypoint.sh: line 4: ./wait-for: Permission denied

1 Like

(moved message here) I read your post before trying Vermin’s solution, and decided to enable executable permissions for others & groups on the wait-for file. I did not encounter the issue you mentioned. Wondering if you did the same?

Hi rogith.

Near the end of the course I did have to address the wait-for error and if memory serves it was by changing the permissions.

But I have to say I encountered so many problems following along with this Docker course that 75% of my time was spent on trial and error and online research to issues that shouldn’t have come up in the first place. I felt like this course was put together hastily, not to mention somewhat outdated at the time it was published. I’ve done a couple of Mosh’s other courses in the past and the experiences were pleasant. This one has left a sour taste in my mouth.

1 Like

Good grief, thank you so much. I have been trying to do complex RUN chmod commands and injecting installations into my containers to make it work. You are my hero. Where can I send the whisky? lol

Well… I am also very thankful to Vermin, he’s answer was very helpful. I’ve been struggling with this for hours.

@faintsignal to solve your last issue, just copy the entry point after the copy command for the package.json (also individually, so the file will belong to your user).

Add this: COPY --chown=app:app docker-entrypoint.sh ./

Same. Kudos to @Vermin . How were you able to find the solution?