I have some services built in Go and I ma deploying them using docker-compose.
I have also linked the services, but now if I do a GET request from one application to other I get unsupported protocol scheme. This is because I am using the service name in the URL without specifying any protocol. Linking and querying works fine with mongoDB but not with other services.
Go service1 File
url :="service2/get" // this is not working
response, err := http.Get(url)
if err != nil {
fmt.Printf("%s", err)
} else {
//do something
}
Docker-compose
service1:
container_name: 'service1'
build: 'service1'
ports:
- '8080:8080'
depends_on:
- 'service2'
links:
- 'service2'
service2:
container_name: 'service2'
build: 'service2'
ports:
- '9001:9001'
Any suggestion how this can be done?
It worked if we use like this
url :="http://service2:9001/get" // this is not working
response, err := http.Get(url)
if err != nil {
fmt.Printf("%s", err)
} else {
//do something
}