In docker we have -t
flag to keep containers from exiting. How can achieve the same thing in nomad?
I want to debug if I can ping one service from another, so I just want a container with curl. However, if I try to deploy the ubuntu image specifying it like below it exits and keeps restarting. What can I do so it just keeps running?
task "testubuntu" {
driver = "docker"
config {
image = "ubuntu:latest"
}
resources {
cpu = 500
memory = 256
network {
mbits = 10
}
}
}
Another solution would be to set a "dummy" entry point tail -f /dev/null
task "testubuntu" {
driver = "docker"
config {
image = "ubuntu:latest"
entrypoint = [
"tail", "-f", "/dev/null",
]
}
resources {
cpu = 500
memory = 256
}
}
It is particularly useful, when you have a task that errors at the container startup but there is not much useful information in the logs. This "dummy" entry point will keep container alive allowing you to get inside container and execute a real startup command with attached debugger for example.
Apart from tail -f /dev/null
, you can also simply use yes
as an entry point. However, it will pollute stdout and affect your logging solution if it is setup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With