title: Exposing docker to the world
body: <p>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 <code>docker exec -it</code> to it, and it works.</p>
  
  <p>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 <code>curl localhost</code>, I get a Connection refused error. </p>
  
  <p>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.</p>
  
  <p>Googling around, I see people referencing <code>docker-machine</code>. 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.... <strong>is this all nescessary?</strong></p>
  
  <p>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?</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>#####################
  ## 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 &amp;&amp; \
      curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &amp;&amp; \
      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 &amp;&amp; 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 }' &gt; /root/.bowerrc &amp;&amp; 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
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3'
  
  services:
    web:
      build: .
      ports:
        - 8080:80
      volumes:
        # Upload folders should be local 
        - ./upload:/usr/local/tomcat/webapps/portal/upload:rw 
  </code></pre>