[英]Is it possible to use a local Docker image in a docker-compose file for DockerComposeContainer?
[英]How to use local Docker image with docker-compose?
我有一個docker-compose文件,希望能夠從本地緩存中的圖像中旋轉出其中一張圖像,而不是從dockerhub中拉出圖像。 我正在使用sbt docker插件,因此我可以看到正在創建的映像,並且可以在命令行中執行docker images
時看到。 但是,當我執行docker-compose up -d myimage
它始終默認為遠程映像。 如何強制它使用本地圖像?
這是我的撰寫文件的相關部分:
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
您可以通過重新使用現有圖像來強制使用本地圖像:
docker tag remote/image local_image
然后在撰寫文件中使用local_image
而不是remote/image
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.