March 2, 2018, 5:48pm
https://github.com/drone/drone/issues/2362 earlier which describes the problem.
drone exec is not consistent with the following drone.yml
- sleep 10
- psql -U postgres -d test -h database -c "SELECT * FROM pg_catalog.pg_tables;"
Sometimes succeeds but most of the time it fails with the following error
[ping:L15:10s] psql: could not translate host name "database" to address: Name or service not known
To trigger a success I need to change the service name from ‘database’ to something else and then it succeeds for the next run or for a couple of runs then it goes back to the above error. Very annoying.
- sleep 10
- psql -U postgres -d test -h database -c “SELECT * FROM pg_catalog.pg_tables;”
The yaml file works as-is for me, without modification
March 2, 2018, 6:16pm
It’s more consistent in Ubuntu … 0 failures after a few executions :S
docker version 17.12.0-ce, build c97c6d6
If you kill the CLI while it is running, it may not have time to cleanup the
drone_default network, which could impact subsequent executions.
March 2, 2018, 6:24pm
docker network ls returns (amongst others)
1fc1ec378ea5 drone_default bridge local
0dfda9901367 drone_default bridge local
b64590d836e2 drone_default bridge local
10eb13a4f2dc drone_default bridge local
63bfe0c48e3d drone_default bridge local
Yes, you need to remove those. That happens if the CLI gets killed and is unable to cleanup after itself. This has been discussed in prior threads 
Multiple drone_default networks created with services
 Service hostname is intermittently being resolved to wrong IPs
March 2, 2018, 6:31pm
yeah, worked after I removed the networks manually. Do you think the same can happen on the actual drone server? Because I’ve noticed inconsistent behaviour there as well.
No, the server creates a unique network name per-pipeline execution.
March 8, 2018, 2:41pm
docker network prune comes handy when you do exec frequently.
March 8, 2018, 3:05pm
Thanks for the tip laszlocph. Still find it strange that the drone cli allows you to be in that erroneous state without providing any warnings.
April 4, 2018, 8:32am
In the most recent version I see that if you have multiple drone networks, the CLI warns you about them and you can clean them up.