如何从本地 docker 图像中找到游牧者的工作
How can nomad' job from local docker images
nomad docker 图像将从 Docker Hub.But 我想使用一些本地 images.How 我可以使用主题吗?(我不想使用私人仓库)
示例我想使用本地图片test
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test latest da795ca8a32f 36 minutes ago 567MB
job "test" {
datacenters = ["dc1"]
group "example" {
task "test" {
driver = "docker"
config {
image = "test"
}
resources {
cpu = 500
memory = 256
}
}
}
}
错了!
查看Nomad的源码here and here,似乎不支持使用机器本地图片。这是有道理的,因为在具有多个节点的集群环境中,调度程序需要能够获取图像,而不管作业分配给哪台机器。
(一种可能的解决方法是 运行 Nomad 集群中的注册表服务,使用 whichever storage backend 对您来说最方便)
Nomad 现在 supports tar docker 图片。
这里有一个例子
artifact {
source = "http://path.to/redis.tar"
}
config {
load = "redis.tar"
image = "redis"
}
但是,tar 大小可能太大而无法弹性传输和配置。
我不确定这是否可以视为答案或“hack”。
但是如果您希望 Nomad 使用节点上已经存在的 docker 图像,则该图像不得标记为最新。
为了测试,我将图像标记为 IMAGE:local
。这样 Nomad 在存在时使用它,在不存在时从远程拉取它。
而@Miao1007 s works, you need to be aware of one thing. It seems that you you cannot use the tag latest or omit the tag altogether ( see the discussion here)。您需要使用一些版本号标记您的 docker 构建,例如
sudo docker build --tag dokr:1.0.0 .
sudo docker save dokr:1.0.0 > dokr-1.0.0.tar
then use the following in the job file
artifact {
source = "http://localhost:8000/dokr-1.0.0.tar"
}
config {
load = "go-docker-dokr-1.0.0.tar"
image = "go-docker-dokr:1.0.0"
}
nomad docker 图像将从 Docker Hub.But 我想使用一些本地 images.How 我可以使用主题吗?(我不想使用私人仓库)
示例我想使用本地图片test
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test latest da795ca8a32f 36 minutes ago 567MB
job "test" {
datacenters = ["dc1"]
group "example" {
task "test" {
driver = "docker"
config {
image = "test"
}
resources {
cpu = 500
memory = 256
}
}
}
}
错了!
查看Nomad的源码here and here,似乎不支持使用机器本地图片。这是有道理的,因为在具有多个节点的集群环境中,调度程序需要能够获取图像,而不管作业分配给哪台机器。
(一种可能的解决方法是 运行 Nomad 集群中的注册表服务,使用 whichever storage backend 对您来说最方便)
Nomad 现在 supports tar docker 图片。
这里有一个例子
artifact {
source = "http://path.to/redis.tar"
}
config {
load = "redis.tar"
image = "redis"
}
但是,tar 大小可能太大而无法弹性传输和配置。
我不确定这是否可以视为答案或“hack”。
但是如果您希望 Nomad 使用节点上已经存在的 docker 图像,则该图像不得标记为最新。
为了测试,我将图像标记为 IMAGE:local
。这样 Nomad 在存在时使用它,在不存在时从远程拉取它。
而@Miao1007 s
sudo docker build --tag dokr:1.0.0 .
sudo docker save dokr:1.0.0 > dokr-1.0.0.tar
then use the following in the job file
artifact {
source = "http://localhost:8000/dokr-1.0.0.tar"
}
config {
load = "go-docker-dokr-1.0.0.tar"
image = "go-docker-dokr:1.0.0"
}