8

I have a docker-compose file and want to be able to make one of the images be spun up from the image in my local cache vs. pulling from dockerhub. I'm using the sbt docker plugin, so I can see the image being created, and can see it when I do docker images at the command line. Yet, when I do docker-compose up -d myimage it always defaults to the remote image. How can I force it to use my local image??

Here is the relevant part of my compose file:

spark-master:
    image: gettyimages/spark:2.2.0-hadoop-2.7
    command: bin/spark-class org.apache.spark.deploy.master.Master -h spark-master
    hostname: spark-master
    environment:
      MASTER: spark://spark-master:7077
      SPARK_CONF_DIR: /conf
      SPARK_PUBLIC_DNS: localhost
    expose:
      - 7001
      - 7002
      - 7003
      - 7004
      - 7005
      - 7006
      - 7077
      - 6066
    ports:
      - 4040:4040
      - 6066:6066
      - 7077:7077
      - 8080:8080
    volumes:
      - ./conf/master:/conf
      - ./data:/tmp/data

  hydra-streams:
    image: ****/hydra-spark-core
    command: bin/spark-class org.apache.spark.deploy.worker.Worker spark://spark-master:7077
    hostname: worker
    environment:
      SPARK_CONF_DIR: /conf
      SPARK_WORKER_CORES: 2
      SPARK_WORKER_MEMORY: 1g
      SPARK_WORKER_PORT: 8881
      SPARK_WORKER_WEBUI_PORT: 8091
      SPARK_PUBLIC_DNS: localhost
    links:
      - spark-master
    expose:
      - 7012
      - 7013
      - 7014
      - 7015
      - 7016
      - 8881
    ports:
      - 8091:8091
    volumes:
      - ./conf/worker:/conf
      - ./data:/tmp/data
flybonzai
  • 3,763
  • 11
  • 38
  • 72
  • My answer below should work. You need to tag the images `****/hydra-spark-core` ... since they contain a path to the remote repository. – yamenk Apr 12 '18 at 16:04
  • @yamenk so if my image id were abcd, the command would be docker tag abcd ****/hydra-spark-core? Or the other way around – flybonzai Apr 12 '18 at 16:21
  • 1
    Yes. Since the first part of the name specifies the remote repository to download the image from – yamenk Apr 12 '18 at 16:26

1 Answers1

14

You can force using the local image by retaging the existing image:

docker tag remote/image local_image

And then inside the compose file using local_image instead of remote/image.

yamenk
  • 46,736
  • 10
  • 93
  • 87
  • 11
    I'm sorry, could you explain in a bit more depth? I'm pretty new to Docker. – flybonzai Apr 12 '18 at 16:12
  • 1
    What worked in particular for me was not adding a tag at the end. That is use "image_name_local" instead "image_name:local". – korulis Nov 07 '19 at 11:05
  • @flybonzai When you have the "remote/" part in the repository name it will default to downloading it from there. Therefore when you retag the image without that part it will use the image it finds locally. – Marcell Apr 18 '23 at 08:46