Commands are not run inside the docker image specified for a build step
Summary
Commands are not run inside the docker image specified for a build step.
Steps to reproduce
Run gitlab-runner exec docker docker_execution_test
in the console.
The contents of the .gitlab-ci.yml
file is:
docker_execution_test:
image: debian:9
script:
- pwd
- la
Example Project
(If possible, please create an example project here on GitLab.com that exhibits the problematic behaviour, and link to it here in the bug report)
(If you are using an older version of GitLab, this will also determine whether the bug has been fixed in a more recent version)
What is the current bug behavior?
Instead of executing the commands inside the container based on the image specified, they are run in the gitlab-runner
docker container:
Runtime platform arch=amd64 os=darwin pid=65390 revision=3afdaba6 version=11.5.0
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 11.5.0 (3afdaba6)
Using Docker executor with image debian:9 ...
Pulling docker image debian:9 ...
Using docker image sha256:4879790bd60d439cfe39c063660eef7af525d5f6f1cbb701a14c7cfc11cbfcf7 for debian:9 ...
Running on runner--project-0-concurrent-0 via theia.local...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out bb973ec4 as master...
Skipping Git submodules setup
$ pwd
/builds/project-0
$ ls
README.md
Job succeeded
What is the expected correct behavior?
db@theia:~/git/docker_test (master*)$ docker run -it --rm debian:9 ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
db@theia:~/git/docker_test (master*)$ docker run -it --rm debian:9 pwd
/
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.4.5p335 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.1 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.1 Go Version: unknown
GitLab information Version: 11.5.1 Revision: c90ae59 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://gitlab.easybell.de HTTP Clone URL: https://gitlab.easybell.de/some-group/some-project.git SSH Clone URL: git@gitlab.easybell.de:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 8.4.1 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Checking GitLab Shell ...
GitLab Shell version >= 8.4.1 ? ... OK (8.4.1) hooks directories in repos are links: ... 2/1 ... ok 11/2 ... ok 15/3 ... ok 18/6 ... ok 18/7 ... ok 15/9 ... ok 15/10 ... ok 15/11 ... ok 15/12 ... ok 15/13 ... ok 15/14 ... ok 14/15 ... ok 15/16 ... ok 20/17 ... ok 18/18 ... ok 18/19 ... ok 20/20 ... ok 15/21 ... ok 15/22 ... ok 23/23 ... ok 15/24 ... ok 15/25 ... ok 14/27 ... ok 2/28 ... ok 23/29 ... ok 15/30 ... ok 15/31 ... ok 20/32 ... ok 20/33 ... ok 23/34 ... ok 10/36 ... ok 10/37 ... ok 15/38 ... ok 14/39 ... ok 20/40 ... ok 23/41 ... ok 10/42 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 11/2 ... yes 15/3 ... yes 18/6 ... yes 18/7 ... yes 15/9 ... yes 15/10 ... yes 15/11 ... yes 15/12 ... yes 15/13 ... yes 15/14 ... yes 14/15 ... yes 15/16 ... yes 20/17 ... yes 18/18 ... yes 18/19 ... yes 20/20 ... yes 15/21 ... yes 15/22 ... yes 23/23 ... yes 15/24 ... yes 15/25 ... yes 14/27 ... yes 2/28 ... yes 23/29 ... yes 15/30 ... yes 15/31 ... yes 20/32 ... yes 20/33 ... yes 23/34 ... yes 10/36 ... yes 10/37 ... yes 15/38 ... yes 14/39 ... yes 20/40 ... yes 23/41 ... yes 10/42 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.4.5) Git version >= 2.9.5 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 22
Checking GitLab ... Finished
From looking at the runners source code, this should be where the cmd is stored for execution within the container: https://gitlab.com/gitlab-org/gitlab-runner/blob/master/executors/docker/executor_docker.go#L860