How to fix 'Permission denied' in Docker sh entrypoint

Phyremaster

I'm trying to create an easy-to-use Docker image for the Garry's Mod server. While my Docker image builds just fine, running it as a container always results in a single error: /bin/sh: 1: ./easygmod.sh: Permission denied.

I'm using the cm2network/steamcmd image as a base. I have tried both tags that the aforementioned base image has. I have tried chmod +x, changing users to root, and fiddling with the shebang in the first line of the easygmod.sh script, as well as a number of possible typos, particularly in file names and paths.

I have a GitHub repository for this project which auto-builds to Docker Hub. Currently, the lines of code involving the problematic script are:

# Start main script
ADD easygmod.sh .
RUN chmod +x easygmod.sh
USER steam
CMD ./easygmod.sh

Also, the shebang/first line of the script is currently #!/bin/sh.

Despite having no logical explanation, the easygmod.sh script refuses to be executed, always throwing the error Permission denied. This especially confusing given that my only other public GitHub project, which is very similar (similar style Docker image with the same base OS as cm2network/steamcmd), never had any issues like this.

Joseph Sible-Reinstate Monica

The file isn't owned by steam in the container, so the chmod +x was insufficient. Either add --chown=steam to the ADD, or change your chmod from +x to a+rx.

Also, you didn't specify CWD or a path to put those files in. It's likely that the root version of that image has a CWD that steam can't access. You should use /home/steam/ for that instead.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Permission denied docker-entrypoint.sh

podman MongoDB docker-entrypoint.sh permission denied

How to fix docker: Got permission denied issue

Error: Starting container process caused "exec: \"/docker-entrypoint.sh\": permission denied"

Docker-compose "exec: \"/usr/src/app/entrypoint.sh\": permission denied"

Docker-compose doesn't work on ubuntu 20.04 [permission denied entrypoint.sh]

Wazuh Indexder throws /entrypoint.sh permission denied after running `docker-compose up`

How to fix bin/sh: can't create /etc/sysctl.conf: Permission denied when running docker-compose?

How to fix 'Permission denied'?

Amazon ECS - Permission denied when using IAM role on Docker entrypoint

docker entrypoint running bash script gets "permission denied"

Permission denied while executing script entrypoint.sh from dockerfile in Kubernetes

Jenkinsfile: permission denied when running sh step in Docker container

docker-compose up permission denied on sh file

How to fix Permission Denied (Public key) error?

How to fix [Errno 13] Permission denied with openpyxl

How do I fix ngrok permission denied?

How to fix amvavis reporting "permission denied" for clamav

How to fix 'Permission Denied' when using csshX

How to fix denied permission to access a directory if that directory was added during docker build?

HOW to fix 'PermissionError: [Errno 13] Permission denied' in python-crontab in docker image?

docker permission denied for shell script in mysql image placed at docker-entrypoint-initdb.d

entrypoint: "entrypoint.sh" - docker compose

/bin/sh: /root/start-docker.sh: Permission denied when exec command in docker

How to dynamically set environment variables in a docker-entrypoint.sh?

How to copy bash script to docker-entrypoint.sh in Dockerfile?

Docker entrypoint.sh not found

Docker: ./entrypoint.sh not found

docker entrypoint sh file restarting