[docker] Services with same image produce not too meaningful warning
Summary
When using services:alias with the docker executor with 2 or more services using the same image, the runner produces a warning which suggests that the services or aliases would not work:
WARNING: Service <image_name> is already created. Ignoring.
While explicit aliases work as intended (services can be access with those names), the aliases derived from the container images will overlap, produce this warning for the 2nd service, and will only use the derived alias for the 1st service.
To make it clearer to the user, what could not be set up, we should change the warning's content to something like:
WARNING: Could not set up service "${derivedAlias}" with image "${image}" for service ${servicesIndex}, because it already exists; services [${explicitAliases}] are set up successfully. (or similar).
Steps to reproduce
.gitlab-ci.yml
myjob:
services:
- name: nginx:latest
alias: abc
- name: nginx:latest
alias: def
image: bash:latest
script:
# Typically, I would now access each of
# the above services by its unique alias
- ls
-
Actual behavior
WARNING: Service nginx:latest is already created. Ignoring.
Expected behavior
2 services containers called abc and def are created
Relevant logs and/or screenshots
job log
[0KRunning with gitlab-runner 17.10.1 (ef334dcc)[0;m
[0K on basic-instance yxNxumfc8, system ID: s_bcf4c14bf644[0;m
[0K[36;1mResolving secrets[0;m[0;m
section_start:1744756011:prepare_executor
[0K[0K[36;1mPreparing the "docker" executor[0;m[0;m
[0KUsing Docker executor with image bash:latest ...[0;m
[0KStarting service nginx:latest...[0;m
[0KPulling docker image nginx:latest ...[0;m
[0KUsing docker image sha256:4cad75abc83d5ca6ee22053d85850676eaef657ee9d723d7bef61179e1e1e485 for nginx:latest with digest nginx@sha256:09369da6b10306312cd908661320086bf87fbae1b6b0c49a1f50ba531fef2eab ...[0;m
[0;33mWARNING: Service nginx:latest is already created. Ignoring.[0;m
[0KStarting service nginx:latest...[0;m
[0KUsing docker image sha256:4cad75abc83d5ca6ee22053d85850676eaef657ee9d723d7bef61179e1e1e485 for nginx:latest with digest nginx@sha256:09369da6b10306312cd908661320086bf87fbae1b6b0c49a1f50ba531fef2eab ...[0;m
[0KWaiting for services to be up and running (timeout 30 seconds)...[0;m
[0KPulling docker image bash:latest ...[0;m
[0KUsing docker image sha256:a6f5c002ec832d6e6a25c08e60f361308d0e752c78eebf8774d041416f5e0be9 for bash:latest with digest bash@sha256:64defcbc5126c2d81122b4fb78a629a6d27068f0842c4a8302b8273415b12e30 ...[0;m
section_end:1744756016:prepare_executor
[0Ksection_start:1744756016:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m
Running on runner-yxnxumfc8-project-68970336-concurrent-2 via basic-instance...
section_end:1744756016:prepare_script
[0Ksection_start:1744756016:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m[0;m
[32;1mFetching changes with git depth set to 40...[0;m
Initialized empty Git repository in /builds/jessie_premium_group/artifact-test/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out cbf722d0 as detached HEAD (ref is main)...[0;m
[32;1mSkipping Git submodules setup[0;m
section_end:1744756018:get_sources
[0Ksection_start:1744756018:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m[0;m
[0KUsing docker image sha256:a6f5c002ec832d6e6a25c08e60f361308d0e752c78eebf8774d041416f5e0be9 for bash:latest with digest bash@sha256:64defcbc5126c2d81122b4fb78a629a6d27068f0842c4a8302b8273415b12e30 ...[0;m
[32;1m$ ls[0;m
LICENSE
README.md
test
test4t4t5
section_end:1744756019:step_script
[0Ksection_start:1744756019:cleanup_file_variables
[0K[0K[36;1mCleaning up project directory and file based variables[0;m[0;m
section_end:1744756019:cleanup_file_variables
[0K[32;1mJob succeeded[0;m
Environment description
config.toml contents
concurrent = 10
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "basic-instance"
url = "REDACTED"
id = 1
token = REDACTED
token_obtained_at = REDACTED
token_expires_at = REDACTED
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
network_mtu = 0
[[runners]]
name = "basic-instance"
url = "https://gitlab.com"
id = 47014989
token = "REDACTED"
token_obtained_at = REDACTED
token_expires_at = REDACTED
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
network_mtu = 0
Used GitLab Runner version
Version: 17.10.1
Git revision: ef334dcc
Git branch: 17-10-stable
GO version: go1.23.6 X:cacheprog
Built: 2025-03-26T12:24:33Z
OS/Arch: linux/amd64