Imagine: After the mongodb
start, it will dump db2dump
and restore it.
Then, how to implement an "On Run" / "On Ready" event on Docker?
You can use the HEALTHCHECK
to do something like these examples:
- You can see the error
cat: /test.txt: No such file or directory
until the health check is ready. - You can see only one
x
inside/test.txt
after run, because theinit
script was executed only once.
Creating network "tmp_default" with the default driver
Creating tmp_test_1 ... done
Attaching to tmp_test_1
test_1 | + set +e
test_1 | + true
test_1 | + cat /test.txt
test_1 | cat: /test.txt: No such file or directory
test_1 | + sleep 3
test_1 | + true
test_1 | + cat /test.txt
test_1 | cat: /test.txt: No such file or directory
test_1 | + sleep 3
test_1 | + true
test_1 | + cat /test.txt
test_1 | x
test_1 | + sleep 3
test_1 | + true
test_1 | + cat /test.txt
test_1 | x
test_1 | + sleep 3
test_1 | + true
test_1 | + cat /test.txt
test_1 | x
test_1 | + sleep 3