I recreated the minimally viable container config for running Postgres mirroring what I configure to run with Docker or Docker Compose. I get errors related to permissions and missing files when the container starts up. Could someone guide me towards an understanding of how implicitly mounted volumes would behave differently between docker run
and this Nomad job?
job "postgres" {
type = "service"
group "postgres" {
count = 1
task "postgres" {
driver = "docker"
config {
image = "postgres:16"
}
env {
POSTGRES_PASSWORD = asdf
}
}
}
update {
max_parallel = 1
min_healthy_time = "5s"
healthy_deadline = "3m"
auto_revert = false
canary = 0
}
}
I can’t reproduce. I copied your config and started and it run fine. The resulting container has /var/lib/postgresql/data
automounted by itself. The implicit docker volumes should work the same. Archlinux Nomad-v1.7.2 docker-v24.0.7 .
$ docker inspect postgres-b07c5058-3254-30a2-8070-81f99d98b455 | jq '.[].Mounts'
[
{
"Type": "volume",
"Name": "ba18699e17374843517bc1bd2ab009a7d84f8281e0ea7595bea99c26cecf7335",
"Source": "/var/lib/docker/volumes/ba18699e17374843517bc1bd2ab009a7d84f8281e0ea7595bea99c26cecf7335/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "bind",
"Source": "/var/lib/nomad/alloc/b07c5058-3254-30a2-8070-81f99d98b455/alloc",
"Destination": "/alloc",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/lib/nomad/alloc/b07c5058-3254-30a2-8070-81f99d98b455/postgres/local",
"Destination": "/local",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/lib/nomad/alloc/b07c5058-3254-30a2-8070-81f99d98b455/postgres/secrets",
"Destination": "/secrets",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
]
Maybe it’s a variance on MacOS. Thanks for trying to recreate. I’ll use Vagrant for local dev so my environment mirrors my deploy.