Wierd issue with query service via rest endpoint on a cb instance in docker

Hi, I am running into a really weird issue that I just cant seem to figure out. I am running a cb node w/ data, index and query service inside a docker container.

I spin up a CB node, and then execute a shell script to configure the node - set up services, create users, create buckets etc. At the end, I also want to create a Primary index on my bucket. For that,I run the below command:

curl -v --trace -u Administrator:password -X POST http://localhost:8093/query/service -d ‘statement=CREATE PRIMARY INDEX och-primary-index ON och USING GSI’

The issue is that after running this command, I always get a connection refused on port 8093 error.

och-couchbase_1  | + curl -v --trace -u Administrator:password -X POST http://localhost:8093/query/service -d 'statement=CREATE PRIMARY INDEX `och-primary-index` ON `och` USING GSI'
och-couchbase_1  | Warning: --trace overrides an earlier trace/verbose option
och-couchbase_1  | Note: Unnecessary use of -X or --request, POST is already inferred.
och-couchbase_1  | curl: (3) Port number ended with 'p'
och-couchbase_1  | Note: Unnecessary use of -X or --request, POST is already inferred.
och-couchbase_1  |   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
och-couchbase_1  |                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to localhost p
ort 8093: Connection refused

Whats odd is that if I later connect to the same docker container and run the curl command separately, the index is created successfully.

docker exec -it /bin/bash
curl -v --trace -u Administrator:password -X POST http://localhost:8093/query/service -d ‘statement=CREATE PRIMARY INDEX och-primary-index ON och USING GSI’

So, its apparent that couchbase is working fine and my guess is there is some issue related to network while executing the script. Can someone take a look and let me know what gives here… Thanks a ton.

Code:

Dockerfile:
FROM couchbase
COPY configure-node.sh /
RUN [“chmod”, “+x”, “/configure-node.sh”]
ENTRYPOINT [“/configure-node.sh”]

Docker-Compose:
version: ‘2’
services:
och-couchbase:
build:
context: .
dockerfile: Couchbase.Dockerfile
ports:
- 8091:8091
- 8092:8092
- 8093:8093
- 8094:8094
- 11210:11210
environment:
- BUCKET=och

I figured out whats going on! The query service was taking a few seconds to come up and hitting it on port 8093 was throwing a ‘not found’. I introduced a sleep of 20 secs before firing the N1ql and it worked.