firecow / gitlab-ci-local

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

Support specifying user via image:docker:user: #1118

Closed haydenseitz closed 5 months ago

haydenseitz commented 6 months ago

Is your feature request related to a problem? Please describe. GitLab CI supports specifying the docker user to run the docker-executor as: https://docs.gitlab.com/ee/ci/yaml/#imagedocker

Describe the solution you'd like gitlab-ci-local to support the same thing, if possible.

For example, running this CI job will always print root:

test_docker_user:
  image:
    name: ubuntu
    docker:
      user: nobody
  script:
    - whoami
$ gitlab-ci-local test_docker_user 
parsing and downloads finished in 54 ms
test_docker_user starting ubuntu:latest (test)
test_docker_user copied to docker volumes in 2.34 s
test_docker_user $ whoami
test_docker_user > root
test_docker_user finished in 5.41 s

 PASS  test_docker_user

And just to confirm via docker CLI:

$ docker run --rm -it --user nobody ubuntu whoami
nobody

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. I have tried updating script to switch users mid-job, but this is a workaround.

Additional context Add any other context or screenshots about the feature request here.