Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/docker-entrypoint.sh": permission denied #7

Closed
mayconfsbrito opened this issue Jan 17, 2017 · 23 comments
Closed

/docker-entrypoint.sh": permission denied #7

mayconfsbrito opened this issue Jan 17, 2017 · 23 comments

Comments

@mayconfsbrito
Copy link

Hi!

I'm trying to run a composer: 1.3.1 image in my host, but when I try to run the "composer" command the shell returns the message bellow:

Exec: "/docker-entrypoint.sh": permission denied

I just inserted the chmod + x /docker-entrypoint.sh command in my Dockerfile, but the problem continues.

I have inserted the composer entry function in my ~ / .bashrc to load the composer installation of the image.

I'm using the docker-compose to clusterize my environment.

docker-compose.yml

version: '2'
services:
  php:
    build: data/php
    image: php:7.1
    ports:
      - "9000:9000"
    privileged: true
    volumes:
      - ./app:/usr/share/nginx/html
  composer:
    build: data/composer
    image: composer:1.3.1
  web:
    restart: always
    build: data/nginx
    image: nginx:1.10.2
    ports:
      - "8000:80"
    links:
      - php
    privileged: true
    volumes:
      - ./data/nginx/vhost.conf:/etc/nginx/conf.d/default.conf
      - ./data/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./app:/usr/share/nginx/html
      - ./data/log/nginx:/var/log/nginx
networks:
  default:
    external:
      name: myapp

Dockerfile

FROM php:7-alpine

RUN apk --no-cache add curl git subversion openssh openssl mercurial tini bash

RUN echo "memory_limit=-1" > "$PHP_INI_DIR/conf.d/memory-limit.ini" \
 && echo "date.timezone=${PHP_TIMEZONE:-UTC}" > "$PHP_INI_DIR/conf.d/date_timezone.ini"

ENV PATH "/composer/vendor/bin:$PATH"
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV COMPOSER_VERSION 1.3.1

RUN curl -s -f -L -o /tmp/installer.php https://raw.githubusercontent.com/composer/getcomposer.org/2091762d2ebef14c02301f3039c41d08468fb49e/web/installer \
 && php -r " \
    \$signature = '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30'; \
    \$hash = hash('SHA384', file_get_contents('/tmp/installer.php')); \
    if (!hash_equals(\$signature, \$hash)) { \
        unlink('/tmp/installer.php'); \
        echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \
        exit(1); \
    }" \
 && php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION} \
 && rm /tmp/installer.php \
 && composer --ansi --version --no-interaction

COPY docker-entrypoint.sh /docker-entrypoint.sh

WORKDIR /app

ENTRYPOINT ["/docker-entrypoint.sh"]

RUN ["chmod", "+x", "/docker-entrypoint.sh"]

CMD ["composer"]
@alcohol
Copy link
Member

alcohol commented Jan 18, 2017

Did you build this image yourself? If so, what umask were you using? Can you show the permissions of the files in your working dir?

@alcohol
Copy link
Member

alcohol commented Jan 18, 2017

I am asking cause I had some issues myself when I was building the image locally, but that was because for some reason (I suspect umask cause I was messing around with that for another project) the permissions were only applied for the owner (none for group or 'other').

rob ~ > docker pull composer
Using default tag: latest
latest: Pulling from library/composer

b7f33cc0b48e: Already exists 
a7d6bcc00046: Already exists 
f3822a33fdb2: Already exists 
49a47789bbdf: Already exists 
b9b85d812300: Already exists 
40930b32d1c2: Already exists 
3cb18ef87fdf: Already exists 
30e3579a0be7: Already exists 
e67e6e017632: Pull complete 
1a5a712a40bc: Pull complete 
5aedcf84ef82: Pull complete 
e3ffe27d034d: Pull complete 
a1c7eab4d2b5: Pull complete 
Digest: sha256:5cd8405d83273030c28d0947b5c9600ee49706e09fe098ddbf7ebb46df0f09b0
Status: Downloaded newer image for composer:latest

rob ~ > docker run -it composer:latest bash

bash-4.3# ls -la /docker-entrypoint.sh 
-rwxrwxr-x    1 root     root          1079 Jan 10 18:32 /docker-entrypoint.sh

When building locally the above would yield me the following, which would not work:

bash-4.3# ls -la /docker-entrypoint.sh 
-rwx------    1 root     root          1079 Dec 30 12:32 /docker-entrypoint.sh

@mayconfsbrito
Copy link
Author

mayconfsbrito commented Jan 18, 2017

Yes, I'm trying to build the image to learn how it works. But this time I'm trying with your image, because it is ready and testand, and after I will use it directly from dockerhub.

The file status on host (including permission):
-rw-rw-r--. 1 maycon maycon 1078 Jan 17 21:14 docker-entrypoint.sh

The file status in the image (accesing with docker run):
-rwxrwxrwx 1 root root 1078 Jan 17 23:14 docker-entrypoint.sh

I run the chmod 777 command in the docker-entrypoint.sh file but the problem still persist.

I will try with the image direct from dockerhub to verify that.

@alcohol
Copy link
Member

alcohol commented Jan 19, 2017

Very peculiar. Can you include a log of your terminal showing the exact commands you ran and the exact error messages it produced?

@herloct
Copy link

herloct commented Jan 28, 2017

I just inserted the chmod + x /docker-entrypoint.sh command in my Dockerfile, but the problem continues.

The file status on host (including permission):
-rw-rw-r--. 1 maycon maycon 1078 Jan 17 21:14 docker-entrypoint.sh

You should make your host's docker-entrypoint.sh executable, not on your Dockerfile.

@alcohol
Copy link
Member

alcohol commented Jan 30, 2017

@herloct is correct. Permissions applied through the Dockerfile might not always apply properly (iirc). You should make sure the file has the executable bit set on your host.

@alcohol alcohol closed this as completed Apr 3, 2017
@kbirger
Copy link

kbirger commented Dec 12, 2017

What is the rationale behind this? I can't control the file system on the machine where my docker image may be built. If I'm building an enterprise application, the machine building the image might be a build server VM. It seems kind of crazy to have to package a pre-build step to change permissions on the file before running docker build

@alcohol
Copy link
Member

alcohol commented Dec 13, 2017

The rationale behind this, is that I did not invent Docker, and as such, I do not know the intricate inner workings of their tooling. You are looking in the wrong place for answers to your question. This repo is for the Composer image and related Dockerfile, not for questions about how or why certain things in Docker work the way they do.

@glensc
Copy link

glensc commented Dec 13, 2017

you may want to track/upvote moby/moby#34819

@sam-mit
Copy link

sam-mit commented Dec 15, 2017

Try exposing volume with :z option in the end.

volumes:
    - host_folder:docker_folder:z

@zoryamba
Copy link

zoryamba commented Mar 2, 2018

used
ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
works for sure without using chmod

@brunowego
Copy link

After run chmod +x entrypoint.sh on my host machine, works. Thanks @herloct.

@maitrungduc1410
Copy link

The solution of @zoryamba works like a charm! 👍

@MagicJohnJang
Copy link

You got to chmod the script to proper permission on the host, before you build the image.

@misoso
Copy link

misoso commented Jun 25, 2019

it work for me, thank you @zoryamba

gabfr added a commit to gabfr/work-around-the-world that referenced this issue Sep 24, 2019
Avoiding permission errors with the entrypoint.sh
Moreover, read this: composer/docker#7
@ichux
Copy link

ichux commented Feb 10, 2020

used
ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
works for sure without using chmod

You saved me a great deal. Thank you so much

@JoseFMP
Copy link

JoseFMP commented May 20, 2020

For me none of the solutions mentioned worked. Furthermore, I do not have in my host a docker-entrypoint.sh file. Are you sure this is not in the container?

@sajcics
Copy link

sajcics commented May 25, 2020

I have the same situation as you @JoseFMP. what ever I tried it's showing docker-entrypoint.sh: Permission denied, and also I don't have docker-entrypoint at my host.

UPDATE: I removed docker and docker-compose completely from project, and installed again, everything work fine! What caused my issue, I am not sure....so I don't have this issue any more.

@glensc
Copy link

glensc commented May 25, 2020

@JoseFMP @sajcics create new bug report, with all details from your system. how you obtained the image, did you built it, what was the build context, etc.

dragging along old and closed issues does not help anyone. it's too confusing to any volunteer even to dig into the problem to explain what even your "me too" means.

@rafalstepien
Copy link

Exact same issue as @JoseFMP and @sajcics

@hadpro24
Copy link

hadpro24 commented Aug 7, 2020

used
ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
works for sure without using chmod

Thanks

@ildarius
Copy link

Complete reinstall of docker is the only thing that helped

sWintermute pushed a commit to sWintermute/geoview that referenced this issue Oct 12, 2021
@pvSource
Copy link

pvSource commented Feb 4, 2024

Previous tips didn't help me.
My troubles were in host machine user rights.

Solving (Windows 11):
PowerShell (Run as administrator) -> wsl -> sudo docker ...
(Running all docker commands as root user and with --no-cache flag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests