yerassyl
yerassyl

Reputation: 3048

Gitlab CI with shell executor and docker image as base

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?

Upvotes: 4

Views: 7238

Answers (2)

Kazimir Podolski
Kazimir Podolski

Reputation: 348

It says (now?) you use docker executor to run jobs in containers

Register a runner so that all jobs run in Docker containers. Do this by choosing the Docker executor during registration.

Like other answer says, you still can run docker commands with shell executor set up to use host's docker just like you would do in local terminal.

Upvotes: 0

MrBerta
MrBerta

Reputation: 2748

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

Upvotes: 5

Related Questions