Error when running Docker with entrypoint script in Linux VM

docker
2.0
linux

#1

Hi there, let me start off by describing the issue I am having and then I’ll paste config files and error outputs.

I am running several dockers inside the CircleCI Linux VM when configured with machine: true and I am building and then running a docker inside and running the docker is always failing with the following error message

docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH".

Exited with code 127

I’ve tried these docker commands locally on my laptop and they’re working fine, though I believe there might be something “special” about CircleCi’s environment and I’m not able to wrap my head around this.

Here’s the circleci job from my config.yml

test-performance:
	machine: true
	working_directory: ~/repo
	steps:
	  - checkout
	  - run: sudo modprobe ifb numifbs=1
	  - run: docker pull sitespeedio/sitespeed.io:8.2.2
	  - run: docker pull nginx:1.15.2-alpine
	  - restore_cache:
		  keys:
			- v1-dependencies-{{ checksum "package.json" }}
			- v1-dependencies-
	  - run: npm install
	  - save_cache:
		  paths:
			- node_modules
		  key: v1-dependencies-{{ checksum "package.json" }}
	  - run: npm run build
	  - run: docker build --rm -f Dockerfile -t github-battle:latest .
	  - run: docker run --rm --name github-battle -d -p 8080:8080 github-battle:latest
	  - run: docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:8.2.2 --summary-detail true http://host.docker.internal:8080/
	  - run: docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:8.2.2 --summary-detail true http://host.docker.internal:8080/battle
	  - run: docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:8.2.2 --summary-detail true http://host.docker.internal:8080/popular
	  - run: docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:8.2.2 --summary-detail true http://host.docker.internal:8080/battle/results?playerOneName=tylermcginnis&playerTwoName=ryanflorence
	  - run: docker container stop github-battle

It should run fine except for when it executes line 20

- run: docker run --rm --name github-battle -d -p 8080:8080 github-battle:latest

This is the full output of the error

#!/bin/bash -eo pipefail
docker run --rm --name github-battle -d -p 8080:8080 github-battle:latest
37551b458cd897e54457ddf9adf62f5a4396a5a2f55a1dbc7347e01b786640a0
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container 
process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH".
Exited with code 127

Any help is greatly appreciated, I am not sure what the error is except that the file cannot be found, though the file “docker-entrypoint.sh” should be there in the working directory ~/repo so not sure why it is referencing $PATH here.

Thanks for any help I can get.


#2

I think the problem is likely with your Dockerfile and the way you’re building your image.

Entrypoint won’t look at your working directory for executables unless your working directory is included in $PATH. You could probably specify your entrypoint with a relative path from your working directory, ./docker-entrypoint.sh rather than just docker-entrypoint.sh.

Could also rename docker-entrypoint.sh to something more descriptive and move it into a directory included in $PATH, assuming the location of the script doesn’t matter when you run it.

Have you tried building and running your Docker image locally?


#3

Hey thanks for the reply!

So yes building the docker image locally works fine. I was referencing the docker-entrypoint.sh in a relative way. Below is my Dockerfile (I should have added it in my initial post)

FROM nginx:1.15.2-alpine

WORKDIR /
COPY ./dist /var/www
COPY nginx.conf /etc/nginx/nginx.conf
COPY docker-entrypoint.sh /usr/local/bin
RUN ln -s usr/local/bin/docker-entrypoint.sh /
ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

I did as you suggested and made the tried ENTRYPOINT ["docker-entrypoint.sh"] and I got a

docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container 
process caused "exec: \"/usr/local/bin/docker-entrypoint.sh\": permission denied".
Exited with code 126

I tried the same with ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] but same error as above.

It is weird that this is working locally (I’m on Windows 10) all the entry points I’m trying build and run successfully with Docker on Windows.


#4

I think you need to add a RUN chmod +x docker-entrypoint.sh in your Dockerfile to make it executable. I can’t recall how file permissions in containers work with Docker on Windows.


#5

That worked!

So it was that 1) I wasn’t referencing the right path and 2) executable permission.


closed #6

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.