[Docker] lesson 12 < section 6 (Running Multi-container Applications) - error and solution

Hi,

for those that had an error in running the api container with following error:

./docker-entrypoint.sh: Permission denied

the solucion is give it a execution permission like as root:

RUN chmod +x docker-entrypoint.sh

and in yml file instead of command i use entrypoint:

entrypoint: ['sh', './docker-entrypoint.sh']

so the in api dockerfile is:

FROM node:14.16.0-alpine3.13

WORKDIR /app
RUN addgroup app && adduser -S -G app app && chown -R  app /app

USER app
COPY package*.json ./
RUN npm install
COPY . . 

USER root
RUN chmod +x ./docker-entrypoint.sh

# you can choose define entrypoint here or in yml file
#ENTRYPOINT ["sh", "./docker-entrypoint.sh"]

USER app

EXPOSE 3001 

CMD ["npm", "start"]

in yml file :

version: '3.8'

services:
  web:
    build: ./frontend
    ports:
      - 3000:3000
    volumes:
      # keep node_modules folder with anonymous volume
      - /app/node_modules
      # bind volume to your host
      - ./frontend:/app

  api:
    build: ./backend
    ports:
      - 3001:3001
    environment:
      DB_URL: mongodb://db/vidly
    volumes:
      # keep node_modules folder with anonymous volume
      - /app/node_modules
      # bind volume to your host
      - ./backend:/app
    # execute the migration script / wait-for
    entrypoint: ['sh', './docker-entrypoint.sh']
  db:
    image: mongo:4.0-xenial
    ports:
      - 27017:27017
    volumes:
      - vidly:/data/db

volumes:
  vidly:

3 Likes

Thank you so much for your answer. It really helped me and saved me lots of time. But I had to remove exiting image and rebuild to make it work. Just want to provide more context for other people.

1 Like

Thanks a ton @jediampm and @xiyi8580 This was very useful. I have labored quite a lot without success trying to resolve this problem. This solution worked for me.

1 Like

It seems as though from this point forward in the course, the information is rather out-of-date. This is disappointing.

1 Like

@jediampm @xiyi8580 Thank you both VERY much! Stuff like this can drive a person crazy trying to fix… especially when, like me, they know just enough to be dangerous :grinning: