1

I am new to Docker and trying to deploy a Microservice in my VM where docker installed, using command

docker run -it -p43011:43011 my-docker-service

the service unable to open DB connection to my company DB server. I am getting Unknown host exception.

Do I need to open any connection between docker container to DB server?

Actually from VM I am able to establish connection to DB server. I am not sure what I am missing here.

this is my DockerFile

FROM alpine:latest
ENV http_proxy=http://proxyserver:9000
ENV https_proxy=http://proxyserver:9000
RUN ( apk fix --no-cache || echo "cannot fix." )
RUN ( apk upgrade --no-cache || echo "cannot upgrade." )
RUN apk add --no-cache --update --upgrade openjdk8
COPY build/libs/my-docker-service.jar /opt/app/
COPY config/application.yml /opt/app/config/
ENTRYPOINT ["java","-jar", "/opt/app/my-docker-service.jar", "--spring.config.location=/opt/app/config/application.yml"]

1 Answer 1

1

Just let the container's network to be the host's network

docker run --net=host -p43011:43011 my-docker-service
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.