title: Docker - cannot access container from Mac Host
body: <p>I can't seem to access a simple Docker container running locally on my mac. I can run <code>curl localhost</code> from the container and see that the default Apache page is served up, but I can't hit it from my machine's browser. </p>
  
  <p>I'm wondering if I have a VirtualBox config issue or something. Any help diagnosing the problem?</p>
  
  <h1>Dockerfile</h1>
  
  <pre><code># Build the image of ubuntu 12.04 LTS
  from ubuntu:precise
  
  # Run apt-get update
  run apt-get -y update
  
  # Install LAMP
  run DEBIAN_FRONTEND=noninteractive apt-get -y install lamp-server^
  run apt-get -y install vim-tiny curl wget
  
  # Put custom scripts in the container and give proper permissions to them
  add ./startup.sh /usr/local/bin/startup.sh
  run chmod 755 /usr/local/bin/startup.sh
  
  add site.vhost /etc/apache2/sites-available/site
  run a2ensite site
  
  # Expose port 80 to the host machine
  expose 80
  </code></pre>
  
  <h1>site.vhost</h1>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
      ServerAdmin webmaster@localhost
  
      DocumentRoot /var/www
      &lt;Directory /var/www/&gt;
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          #Order allow,deny allow from all
      &lt;/Directory&gt;
  
      # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg.
      LogLevel warn
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <h1>startup.sh</h1>
  
  <pre><code>#!/bin/bash
  
  a2dissite default
  apache2ctl graceful
  /usr/bin/mysqld_safe &amp;
  </code></pre>
  
  <h2>To start...</h2>
  
  <p>I'll build the image with <code>docker build -t test1 .</code> - which seems to run fine. </p>
  
  <p>On initial setup, I run <code>docker run -d -v $(pwd)/mysql:/tmp/mysql test1 /bin/bash -c "cp -rp /var/lib/mysql/* /tmp/mysql"</code> to setup MySQL.</p>
  
  <p>Then I run <code>docker run -i -t -v $(pwd)/mysql:/var/lib/mysql -v $(pwd)/www:/var/www -p 8080:80 test1 /bin/bash</code> to start the actual instance. </p>
  
  <p>Once at the terminal, I run <code>service apache2 start</code> and everything seems to be running great. If I run <code>curl localhost</code> I get the default page just fine.</p>
  
  <p>Everything seems great, it's just hitting it from the Host that doesn't work. I should be able to navigate to <code>http://127.0.0.1:8080</code> and have that forward to the container on port 80, right?</p>