dockergitlab-cidocker-multi-stage-build

gitlab shared runner docker does not support multi-stage build


i am running the following docker file in a gitlab runner

FROM alpine:3.18 as alpine
RUN ...

and here is my pipeline

image: gitlab/dind

services:
  - docker:dind


stages:
  - init
  - build
init:
  stage: init
  script:
    git clone MY_REPO
  artifacts:
    paths:
      - cicdtest

build:
  stage: build
  script:
    - docker build -t registry.gitlab.com/mytest cicdtest/. --no-cache

My pipeline fails with this error

Step 1 : FROM alpine:3.18 as alpine
Error parsing reference: "alpine:3.6 as alpine" is not a valid repository/tag

I modified my dockerfile to first pull the image as follows:

image: gitlab/dind

services:
  - docker:dind


stages:
  - init
  - build
init:
  stage: init
  script:
    git clone MY_REPO
  artifacts:
    paths:
      - cicdtest

build:
  stage: build
  script:
    - docker pull alpine:3.18
    - docker build -t registry.gitlab.com/mytest  cicdtest/. --no-cache

but the same error persists. it seems that the error is from the fact that docker --version prints Docker version 1.12.1, build 23cf638 and Multi-stage builds are a new feature requiring Docker 17.05 or higher on the daemon and client. can someone recommend how to bumpup the shared runner docker version to 17.5? docker info prints the following

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.1
Storage Driver: overlay2
 Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host bridge overlay null
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor
Kernel Version: 5.4.109+
Operating System: Ubuntu 14.04.5 LTS (containerized)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.776 GiB
Name: runner
ID: XXXXXXX
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

Solution

  • Replace image: gitlab/dind with image: docker

    gitlab/dind is not a maintained image and was last updated 7 years ago.