Skip to content

Instantly share code, notes, and snippets.

@jahkeup
Last active September 12, 2018 14:34
Show Gist options
  • Save jahkeup/f84251385970e6fb2bb811f9c5efe8c4 to your computer and use it in GitHub Desktop.
Save jahkeup/f84251385970e6fb2bb811f9c5efe8c4 to your computer and use it in GitHub Desktop.
standard_init_linux.go:190: exec user process caused "no such file or directory" - ECS AMI Test

Testing

Drop these two files in the same directory on a host with Make and Docker installed.

Scenarios

missing-script.sh

Entrypoint specified as a missing script at the path.

nointerp.sh

Invalid interpreter specified with the shebang.

nochmod.sh

Script without execution bits set (eg: no chmod +xwas run).

missing-from-path.sh

Script specified a valid interpreter but with invalid exec'd executable (ie: ruby).

Example run:

[ec2-user@ip-172-31-33-108 test]$ make

-- Printing out environment info
date
Wed Sep 12 14:33:00 UTC 2018
curl http://169.254.169.254/latest/meta-data/ami-id
ami-093381d21a4fc38d1
sestatus
SELinux status:                 disabled
rpm -qi docker | grep Version
Version     : 18.06.1ce

-- Building test container
docker build -t scriptcontainer .
Sending build context to Docker daemon  3.584kB
Step 1/2 : FROM busybox:latest
 ---> e1ddd7948a1c
Step 2/2 : RUN echo "#!/no/interpreter" >> /nointerp.sh &&     chmod +x /nointerp.sh &&     echo "#!/bin/env ruby" >> /missing-from-path.sh &&     cp /missing-from-path.sh /nochmod.sh &&     chmod +x /missing-from-path.sh
 ---> Using cache
 ---> da40a8e706a9
Successfully built da40a8e706a9
Successfully tagged scriptcontainer:latest

-- Testing script invocation: with /missing-script.sh
docker run --entrypoint /missing-script.sh --rm scriptcontainer
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/missing-script.sh\": stat /missing-script.sh: no such file or directory": unknown.
make: [test-missing-script] Error 127 (ignored)

-- Testing script invocation: with /nointerp.sh
docker run --entrypoint /nointerp.sh --rm scriptcontainer
standard_init_linux.go:190: exec user process caused "no such file or directory"
make: [test-nointerp] Error 1 (ignored)

-- Testing script invocation: with /nochmod.sh
docker run --entrypoint /nochmod.sh --rm scriptcontainer
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/nochmod.sh\": permission denied": unknown.
ERRO[0000] error waiting for container: context canceled 
make: [test-nochmod] Error 126 (ignored)

-- Testing script invocation: with /missing-from-path.sh
docker run --entrypoint /missing-from-path.sh --rm scriptcontainer
env: can't execute 'ruby': No such file or directory
make: [test-missing-from-path] Error 127 (ignored)
FROM busybox:latest
RUN echo "#!/no/interpreter" >> /nointerp.sh && \
chmod +x /nointerp.sh && \
echo "#!/bin/env ruby" >> /missing-from-path.sh && \
cp /missing-from-path.sh /nochmod.sh && \
chmod +x /missing-from-path.sh
all: env build test
env:
@echo -e "\n-- Printing out environment info"
date
curl http://169.254.169.254/latest/meta-data/ami-id
@echo
sestatus
rpm -qi docker | grep Version
build:
@echo -e "\n-- Building test container"
docker build -t scriptcontainer .
test: test-missing-script test-nointerp test-nochmod test-missing-from-path
test-%:
@echo -e "\n-- Testing script invocation: with /$*.sh"
-docker run --entrypoint /$*.sh --rm scriptcontainer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment