[英]How to use local Docker image with docker-compose?
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. 我有一个docker-compose文件,希望能够从本地缓存中的图像中旋转出其中一张图像,而不是从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. 我正在使用sbt docker插件,因此我可以看到正在创建的映像,并且可以在命令行中执行docker images
时看到。 Yet, when I do docker-compose up -d myimage
it always defaults to the remote image. 但是,当我执行docker-compose up -d myimage
它始终默认为远程映像。 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
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
. 然后在撰写文件中使用local_image
而不是remote/image
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.