You can only have one "default" image that is applied to every step in the pipeline, but you can specify an image to use for each job, or just the jobs that are different from the default.
From the GitLab CI documentation here (https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-image-and-services-from-gitlab-ciyml), you can specify a default for all steps to use:
default:
image: ruby:2.6
services:
- postgres:11.7
before_script:
- bundle install
test:
script:
- bundle exec rake spec
as well as have some steps differ from the default:
default:
image: ruby:2.6
services:
- postgres:11.7
before_script:
- bundle install
test: # this uses the default image
script:
- bundle exec rake spec
db_setup: # this uses a specific image that is different from the default
image: mysql:8
script:
- mysql -h my_datbase.example.com -u root -ppassword -e "create database my_database"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…