I an trying to create a development environment with multiple microservices running like in a production environment.
I would like to run with Docker two rails applications
that makes calls between them.
I know that I can use links
, but with this I always has to run one of them as the master one. That means, that I only can debug this one, and I would like to see the console ouput of each of them. Maybe I am doing something wrong, and that's why I am asking.
This is my docker-compose.yml file:
rails-app-A:
build: .
dockerfile: "DockerfileA"
environment:
RAILS_ENV: development
links:
- db
command: bundle exec rails server -p 3005 -b '0.0.0.0'
volumes:
- ".:/home/app"
volumes_from:
- bundle
expose:
- "3005"
ports:
- "3005:3005"
rails-app-B:
build: .
dockerfile: "DockerfileB"
environment:
RAILS_ENV: development
links:
- db
command: bundle exec rails server -p 3000 -b '0.0.0.0'
volumes:
- ".:/home/app"
volumes_from:
- bundle
expose:
- "3000"
ports:
- "3000:3000"
This is how I run the rails app:
docker-compose run --service-ports rails-app-A
docker-compose run --service-ports rails-app-B
I always get errors like these:
Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 3000
Errno::ECONNREFUSED (Failed to open TCP connection to localhost:3000 (Connection refused - connect(2) for "localhost" port 3000))
The thing is that I can access to all of them with the browser.
With the Docker version for OSX using VirtualBox this was working fine (just calling localhost:3000
or localhost:3005
), but in Ubuntu or with Docker-beta, is failing.
EDIT
I understand that "localhost" for rails-app-A is a different server as "localhost" in rails-app-B, because they run as different machines. When I had VirtualBox
I could access because I had the IP of the VirtualBox instance (192.169.99.100).
I am now using http://localtunnel.me/
and I can access to the other services. But, anyway, Is there a better way to do this?