Unable to dockerize nginx and index.html page

I try to follow this tutorial. So, these are my prerequisites:

  1. ubuntu version is 16.04.1 LTS
  2. docker version is 1.12.6
  3. docker-compose version 1.9.0

My local directory looks like so:

  • “debconf: delaying package configuration, since apt-utils is not installed” :> google notebooks bash error
  • how can I run docker containers in detached mode within a committed image
  • Docker Swarm Distribute Build Image
  • Hazelcast in multinode docker environments with TCPIP
  • Why connect to Google Cloud SQL failed inside Docker container but success outside Docker container?
  • Ping Command inside docker container doesnt work
  • \code
        index.html
    site.conf
    docker-compose.yml
    

    The index.html contents is just “Hello world”.

    The site.conf contents:

    server {
        index index.html;
        server_name php-docker.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /code;
    }
    

    The docker-compose.yml contents:

    web:
      image: nginx:latest
      ports:
      - "8080:80"
      volumes:
      - ./code:/code
      - ./site.conf:/etc/nginx/conf.d/site.conf
    

    And finally in my /etc/hosts file I added to the top this line:

    php-docker.local    127.0.0.1
    

    With all that, when I run this command:

    docker-compose up --force-recreate
    

    And go to php-docker.local:8080, I get “Server not found” error. If however I go to localhost:8080 I see a standard welcoming nginx page. So, what is wrong with that and how can I fix it? Or what can I do to debug it?

  • Docker Best Practises: at what size application should you refrain from containerising?
  • How to access several ports of a Docker container inside the same container?
  • Kubelet image GC for docker “Data Space Total” instead of disk space
  • Deployment of multiple instances of Tomcat in single Dockerfile using Supervisor
  • Docker 1.10 container's IP in LAN
  • Use Docker registry with SSL certifictae without IP SANs
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.