ECS Problem with dial: dial tcp: lookup config-service on 10.0.0.2:53: no such host. Sleeping 1s

cloudytechi147

New Member
Joined
Oct 12, 2021
Messages
4
Reaction score
0
Credits
63
There are two services: config-service and discovery-service

Dockerfile of config-service :

Code:
FROM openjdk:17-alpine
ENV APP_FILE config-service.jar
ENV APP_HOME /app
EXPOSE 8088
COPY build/libs/$APP_FILE $APP_HOME/
WORKDIR $APP_HOME
ENTRYPOINT ["sh", "-c"]
CMD ["exec java -jar $APP_FILE --spring.profiles.active=native,docker"]

Dockerfile of discovery-service :

Code:
FROM openjdk:17-alpine

ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

ENV APP_FILE discovery-service.jar
ENV APP_HOME /app
EXPOSE 8061
COPY build/libs/$APP_FILE $APP_HOME/
WORKDIR $APP_HOME
ENTRYPOINT ["sh", "-c"]
CMD ["exec dockerize -timeout 5m -wait tcp://config-service:8088 java -jar $APP_FILE --spring.profiles.active=docker"]

Therefore, discovery-service waits until config-service are connected. There are no problems while running on local and docker.

For my docker running on localhost, the successful message from discovery-service should be:

Code:
Problem with dial: dial tcp 172.22.0.2:8088: connect: connection refused. Sleeping 1s

Connected to tcp://config-service:8088

However, once I run on AWS ECS, config-service runs perfectly as expected; discovery-service keeps prompting the error per second:

Code:
Problem with dial: dial TCP: lookup config-service on 10.0.0.2:53: no such host. Sleeping 1s

Here are setting on ECS:

Task Definition

I almost set all configs as default. I leave empty for Task role and Task execution role. Only Network mode and compatibilities have been set. awsvpc and Bridge have been tried for Network mode, and EC2 and FARGATE have been tried for compatibilities.

The container inside Task Definition

Port mappings and Hostname for NETWORK SETTINGS are set. 8088 for config-service and 8061 for discovery-service

Cluster

EC2 Linux + Networking template. m5d.large EC2, Security group inbound rule is set to be 8088 and 8061 respectively.

Service

Service is created for Cluster, I use the most basic set. The service type is DAEMON without Load balancing or other add-ons.
Please let me know what's wrong with my setting on ECS. Thank you!


----------------------------
code from Linux web hosting.
 

Members online


Latest posts

Top