I've been searching for this all over the internet too. All you need is to add name for your container and it will be available for othre containers:
docker-compose run --name mycontainer mycontainer <whatever-command-here>
This was exact reason why depedencies couldn't connect to app container.