Build a docker file in one stage and use it in subsequent stage with out pushing it to docker hub

Below is the sample stage template which i want to achieve,

stages:

  • build
  • deploy

build:
stage: build
image:
script:

  • docker build -t myimage .

deploy
stage: deploy
image: myimage
script:

  • echo “it works”

so here am trying to use the image i built in the build stage. Please let me know if its possible.