So I have a Go application that I am deploying to a EC2 instance with Ansible and Jenkins pipeline as a Docker image. I have an image that I can access from outside the host using the IP address and the port number, 8080, using Postman. When I deploy a new image I cannot get a response using the ip address and port number. When I ssh into the server I can reach the endpoint using localhost and the port number. If I stop that image and start the first I can then reach it again.
What are the possible differences between these images that makes it so the endpoint can no longer be accessed via the ip address?
My Docker Compose File:
version: '2'
services:
project-1:
image: ...
volumes:
- /var/log:/var/log
network_mode: host
environment:
- ...
cpu_shares: 1236
mem_limit: 2619m
My DockerFile:
FROM golang:1.10
WORKDIR /go/src/...
COPY . .
RUN go get -d -v ./...
RUN go install -v ./...
EXPOSE 8080-8080
CMD ./run.sh
I have also attempted removing network_mode from Docker Compose file and replacing it with ports as shown below with no success:
ports:
- "0.0.0.0:8080:8080"