Reputation: 23
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"]
Upvotes: 1
Views: 1460
Reputation: 230
Just let the container's network to be the host's network
docker run --net=host -p43011:43011 my-docker-service
Upvotes: 1