2
votes

I am having troubles with gitlab-ci with docker image. Searched a lot in the internet and still confused.

The Problem: I need to use docker image as base for my gitlab ci build.

I am using shell executor, and in my gitlab-ci.yml I defined image like this:

image: "registry.gitlab.com/my_projects/my_repo:latest"

I have this docker images pushed to gitlab registry. It contains core libraries required for my build (ruby, node, npm, etc etc)

I also defined [runners.docker] settings in gitlab-runner/config.toml file, which has some lines like this:

[[runners]]
  executor = "shell"
  [runners.docker]
    services = ["registry.gitlab.com/my_project/my_repo:latest"]

The problem is that gitlab-runner ignores that image.

Here is the tutorial which I used:

https://dev.to/zimski/the-complete-guide-to-setup-a-cicd-for-rails-5-on-gitlab-2f2d

Is it possible to use docker image as base inside shell executor in gitlab-ci?

1

1 Answers

2
votes

When you are using the shell executor, your jobs will be executed just as if you were running that shell manually. If you then want to use a docker image for building, you just have to do it as you would do manually when building using a docker image from your shell.

From the way you write that you want to use the image tag in your .gitlab-ci.yml file and that you are setting the [runners.docker] setting, it sounds like you want to use the docker executor. You can chose this instead of the shell executor when you register your runner. You can find more information about executors here:

https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-executors