Docker Community Forums

Pretty new to docker and was asked to use docker-compose to get two containers working together. I have a service that connects to NATS and it fails if it can’t connect. I’m getting:
panic: nats: no servers available for connection

Here is my compose file:
version: “2”

services:
myservice:
build: .
ports:
- "3421"
depends_on:
- nats
nats:
image: apcera/gnatsd
ports:
- “4222:4222”
- "8333:8333"
I have seen other people talk about this happening sometimes when using databases. They talked about using a script, I guess to test whether the db was up then connect? But didn’t go into detail on how/where to do this(Dockerfile, docker-compose?) Any help or ideas would be greatly appreciated. My environment is:
OS: Unbuntu 14.04
Docker version:
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 05:22:43 2016
OS/Arch: linux/amd64