Search code examples
dockergitlab

How does GitLab run commands in the `node` container?


If I have a .gitlab-ci.yml file like:

image: node:latest

test:
  script:
    - npm install

This runs fine - but if I run docker run --rm -it node:latest, it drops me at a node shell, which doesn't recognise npm:

$ docker run --rm -it node:latest
Welcome to Node.js v21.6.2.
Type ".help" for more information.
> npm install
npm install
npm should be run outside of the Node.js REPL, in your normal shell.
(Press Ctrl+D to exit.)
>

I thought GitLab used whatever shell the container presented - is it secretly doing something like passing /bin/bash or /bin/sh to the docker command to get a shell it can run npm, etc. on?


Solution

  • How does GitLab run commands in the node container?

    The image entrypoint is just set to start a node shell.

    is it secretly doing something like

    Yes.

    https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#where-scripts-are-executed