Docker: command not found in gitlab-ci

Background

in my gitlab-ci file I am trying to build a docker image, however even though I have docker:dind as a service, it is failing.

.gitlab-ci

---
stages:
  - build
  - docker

build:
  stage: build
  image: fl4m3ph03n1x/my-app:1.0
  variables:
    MIX_ENV: prod
  script:
    - mix deps.get
    - mix deps.compile
    - mix compile
  artifacts:
    paths:
      - .hex/
      - _build/
      - deps/
      - mix.lock

build_image:
  stage: docker
  image: fl4m3ph03n1x/my-app:1.0
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
    DOCKER_HOST: tcp://docker:2375/
  services:
    - docker:dind
  script:
    - echo ${CI_JOB_TOKEN} | docker login --password-stdin -u ${CI_REGISTRY_USER} ${CI_REGISTRY}
    - docker build . -t ${CI_REGISTRY_IMAGE}:latest
    - docker push ${CI_REGISTRY_IMAGE}:latest

The problematic stage is docker.
As you can see I am trying to:

  1. login into docker
  2. build an image from gitlab’s registry
  3. push that image

This is the Dockerfile that generates “fl4m3ph03n1x/my-app:1.0”:

---
stages:
  - build
  - docker

build:
  stage: build
  image: fl4m3ph03n1x/my-app:1.0
  variables:
    MIX_ENV: prod
  script:
    - mix deps.get
    - mix deps.compile
    - mix compile
  artifacts:
    paths:
      - .hex/
      - _build/
      - deps/
      - mix.lock

build_image:
  stage: docker
  image: fl4m3ph03n1x/my-app:1.0
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
    DOCKER_HOST: tcp://docker:2375/
  services:
    - docker:dind
  script:
    - echo ${CI_JOB_TOKEN} | docker login --password-stdin -u ${CI_REGISTRY_USER} ${CI_REGISTRY}
    - docker build . -t ${CI_REGISTRY_IMAGE}:latest
    - docker push ${CI_REGISTRY_IMAGE}:latest

Error

However, I am getting the following error:

echo {CI_JOB_TOKEN} | docker login --password-stdin -u
{CI_REGISTRY_USER} {CI_REGISTRY} /bin/bash: line 110: docker:
command not found

Which is confusing, because docker:dind is supposed to actually prevent this from happening:

Question

So clearly I am missing something here. What am I doing wrong?