Reputation: 4233
I've setup an Ubuntu server with docker-ce. Here I'm running a small docker container, which works fine. It starts up a tomcat image, exposing 8080 to local port 80. I've tested docker exec -it
to it, and it works.
But when I throw up my browser and try to reach it through my ubuntu host ip address, I get nothing. If I open a terminal and SSH to my ubuntu server and try to curl localhost
, I get a Connection refused error.
I checked my iptables, and there is a chain for DOCKER present with a source of 0.0.0.0/0 and the exposed tcp dpt:80 port.
Googling around, I see people referencing docker-machine
. This is not installed, so I installed it. This wants me to create something, so I try to create a docker-machine. But this requires virtualbox, so I install that. Virtualbox won't start until I modify my BIOS.... is this all nescessary?
I would think that just installing docker-ce would be enough. It's enough on my local windows box, why can't it be enough on my cloud hosted ubuntu server? What am I missing?
Dockerfile
#####################
## Stage 1: Build ##
# We base this builder on tomcat, as our build script relies heavily
# on tomcat libraries
FROM tomcat:7.0-jre7 as builder
# Install sources
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# We install our build environment (java 1.7, ant and node)
RUN apt-get update && apt-get install -y openjdk-7-jdk ant apt-transport-https nodejs yarn git
# We set the java options needed to compile this
ENV JAVA_OPTS="-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -XX:MaxPermSize=512m"
# Then we copy in our app and libraries used for building it
WORKDIR /usr/src/app
COPY . .
COPY tomcat/lib /usr/local/tomcat/lib
# Run frontend dependency installation (npm and bower)
RUN echo '{ "allow_root": true }' > /root/.bowerrc && yarn install
# We build it (this will also deploy it to this tomcat container
# but the tomcat container will never startup before the build stage
# is discarded)
RUN ant clean init jar-dev-configuration compile deploy
#####################
## Stage 2: Runner ##
FROM tomcat:7.0-jre7-alpine
# Copy in local configuration
COPY tomcat/conf /usr/local/tomcat/conf
COPY tomcat/lib /usr/local/tomcat/lib
# Copy in built products
COPY --from=builder /usr/local/tomcat/webapps/kx /usr/local/tomcat/webapps/kx
COPY --from=builder /usr/local/tomcat/webapps/portal /usr/local/tomcat/webapps/portal
EXPOSE 8080
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- 8080:80
volumes:
# Upload folders should be local
- ./upload:/usr/local/tomcat/webapps/portal/upload:rw
Upvotes: 0
Views: 3796
Reputation: 177
From given information, I can tell, that in your docker-compose.yml
you are exposing port 8080
onto your host machine (thus, to the world) and port 80
into your container.
Try swapping them to:
ports:
# host:container
- 80:8080
Upvotes: 2