firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.36k stars 134 forks source link

Failing to wait for services to start on MacOS Sonoma #1053

Closed earthiverse closed 11 months ago

earthiverse commented 11 months ago

I'm getting this error: docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "mockserver:1080": executable file not found in $PATH: unknown.

Command:

gitlab-ci-local --concurrency=1 test:small

Output:

parsing and downloads finished in 53 ms
test:small                                        starting php:7.1-alpine (test)
test:small                                        copied to docker volumes in 750 ms
test:small                                        started service image: mockserver/mockserver:latest with aliases: mockserver-mockserver, mockserver__mockserver, mockserver in 240 ms
test:small                                        service image: mockserver/mockserver:latest healthcheck failed
test:small                                          Command failed with exit code 127: docker run --rm --name=gcl-wait-for-it-260001-0-1080 --network gitlab-ci-local-260001 docker.io/sumina46/wait-for-it mockserver:1080 -t 30
test:small                                          docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "mockserver:1080": executable file not found in $PATH: unknown.
test:small                                        also see (/Users/earthiverse/Sites/mockserver/.gitlab-ci-local/services-output/testOgsmall/mockserver/mockserver:latest-0.log)
test:small                                        $ return 0
test:small                                        finished in 2.16 s

 PASS  test:small  

/Users/earthiverse/Sites/mockserver/.gitlab-ci-local/services-output/testOgsmall/mockserver/mockserver:latest-0.log

 ### stdout ###

### stderr ###

Minimal .gitlab-ci.yml illustrating the issue

test:minimal:
  image: php:7.1-alpine
  services:
    - name: mockserver/mockserver:latest
      alias: mockserver
  script:
    - return 0

Expected behavior No errors

Host information macOS Sonoma 14.1.2 (Apple Silicon M1 Pro) gitlab-ci-local 4.45.2

firecow commented 11 months ago

Can you provide a Dockerfile for this "mockserver". So I can reproduce.

earthiverse commented 11 months ago

Can you provide a Dockerfile for this "mockserver". So I can reproduce.

I believe this is the one https://github.com/mock-server/mockserver/blob/mockserver-5.15.0/docker/Dockerfile I'm pulling the service from https://hub.docker.com/r/mockserver/mockserver

avoidik commented 11 months ago

wait-for-it.sh script uses bash but there is no bash in the base image of https://hub.docker.com/r/sumina46/wait-for-it ... even if you'd commit bash it will fail, because ENTRYPOINT is not pointing to /usr/local/bin/wait-for-it.sh, as a temporary workaround you could try to override locally cached copy with this

$ curl -fsSLO https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh
$ docker build -t sumina46/wait-for-it:latest -f Dockerfile.waiter .
# Dockerfile.waiter
FROM alpine
COPY wait-for-it.sh /usr/local/bin/wait-for-it.sh
RUN chmod +x /usr/local/bin/wait-for-it.sh
RUN apk --no-cache add bash
ENTRYPOINT ["/usr/local/bin/wait-for-it.sh"]
firecow commented 11 months ago

So wait a minute, your example isn't working on gitlab.com with "real" runners?

earthiverse commented 11 months ago

So wait a minute, your example isn't working on gitlab.com with "real" runners?

It works on my GitLab CI without issues. There aren't any errors in the CI logs.

earthiverse commented 11 months ago

wait-for-it.sh script uses bash but there is no bash in the base image of https://hub.docker.com/r/sumina46/wait-for-it ... even if you'd commit bash it will fail, because ENTRYPOINT is not pointing to /usr/local/bin/wait-for-it.sh, as a temporary workaround you could try to override locally cached copy with this

$ curl -fsSLO https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh
$ docker build -t sumina46/wait-for-it:latest -f Dockerfile.waiter .
# Dockerfile.waiter
FROM alpine
COPY wait-for-it.sh /usr/local/bin/wait-for-it.sh
RUN chmod +x /usr/local/bin/wait-for-it.sh
RUN apk --no-cache add bash
ENTRYPOINT ["/usr/local/bin/wait-for-it.sh"]

I don't see any errors when I do it this way, this works, thanks!

avoidik commented 11 months ago

@firecow I was unable to find a maintainer of the original docker image, here is a commit caused the issue https://github.com/firecow/gitlab-ci-local/commit/90a3d3bab3ebf9778e32a32a0a31a5705160ba8b perhaps @lisn0 can help?

gruberdev commented 11 months ago

I also encountered this issue when trying to run the setup on a Macbook using an M1 Pro (w/ Rosetta).

This suggestion fixed the setup and allowed me to use a Docker-in-Docker properly.

lisn0 commented 11 months ago

Just fixed the Docker image. I sincerely apologize! Should work now. Let me know if you run into any more problems. Thanks for the heads up!