I have a service in the docker compose as follows.
nginx:
image: nginx:1.18.0-alpine
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
- ./entrypoint.sh:/entrypoint.sh
entrypoint: ./entrypoint.sh
depends_on:
- webapp
networks:
- nginx_network
I get the error
Cannot start service nginx: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/entrypoint.sh": permission denied: unknown
ERROR: for nginx Cannot start service nginx: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/entrypoint.sh": permission denied: unknown
ERROR: Encountered errors while bringing up the project.
How can i do this
I have to use ["/bin/sh","/entrypoint.sh"]
nginx:
image: nginx:1.18.0-alpine
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
- ./entrypoint.sh:/entrypoint.sh
entrypoint: ["/bin/sh","/entrypoint.sh"]
depends_on:
- webapp
networks:
- nginx_network
I don't have enough information about your entrypoint script, config file and the web app minimal information.
Sometimes when you create a file on your host machine it lacks some permissions to be executed by some users in your docker container, so Iwould think about checking the permissions for that file by running:
ls -l
that will give you all permissions about that file, and maybe that's why it's telling you permission is denied try adding execution permission running chmod +x ./entrypoint.sh.
I usually do that using a dockerfile when working on a script from my context.
dockerfile
FROM nginx:1.18.0-alpine
COPY /entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]:
docker-compose.yaml
version: "3.8"
services:
nginx:
build:
context: ./
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
depends_on:
- webapp
networks:
- nginx_network
Then try to run:
docker-compose up --build
make sure both files are in the same directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With