Second docker build doesn't see image from first docker build

My circle.yml:

machine:
  services:
    - docker

dependencies:
  cache_directories:
    - ~/docker
  override:
    - docker info
    - ./docker/build-indexer-circleci.sh

My ./docker/build-indexer-circleci.sh is:

#!/bin/bash
sha1=`git log -1 --pretty=format:%h`

docker build --rm=false -t lidar-indexer-base:latest -t lidar-indexer-base:${sha1} -f Dockerfile.indexer-base .
docker build --rm=false -t lidar-indexer -t lidar-indexer:${sha1} -f Dockerfile.indexer .

Dockerfile.indexer starts with:

FROM lidar-indexer-base:latest

The problem is that second build fails with:

Step 1 : FROM lidar-indexer-base:latest
Pulling repository docker.io/library/lidar-indexer-base
Error: image library/lidar-indexer-base:latest not found

./docker/build-indexer-circleci.sh returned exit code 1

It works for me locally but on CircleCI it looks like second docker build command doesn’t see local image lidar-indexer-base:latest built in the first step. It tries to pull it from docker hub, which doesn’t have it.

Any idea how to make docker build see local lidar-indexer-base:latest instead of looking for it on docker hub?

Needless to say, I don’t want to push the image to external docker registry and have it re-downloaded.