ThisIsNoZaku
ThisIsNoZaku

Reputation: 2443

Bash script within Docker container unexpected "permission denied"

I am using the amazonlinux image to test a server setup script without spending time and money on real EC2 instances. However, I cannot get the script to execute within the container.

I am running with the following command: `docker run -v script.sh:/tmp/script.sh -w /tmp amazonlinux ./script.sh

Which fails with "Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./script.sh\": permission denied": unknown.

  1. The script permissions are -rwxrwxrwx on the host.
  2. Permissions inside the container are drwxr-xr-x.
  3. The user in the container is root.

Upvotes: 2

Views: 1180

Answers (1)

Maoz Zadok
Maoz Zadok

Reputation: 5930

Try this: docker run -v ${PWD}/script.sh:/home/root/script.sh -w /home/root amazonlinux ./script.sh

Upvotes: 1

Related Questions