Docker – invalid sharing of index.html Nginx file

I have my docker-compose.yml file like so:

web:
  image: nginx:latest
  volumes:
    - /c/Users/marcin/docker/nginx-www/nginx/html/:/usr/share/nginx/html/ 
  ports:
    - "80:80"

In /c/Users/marcin/docker/nginx-www/nginx/html/ I’ve created index.html file with the following content:

  • Howto link a prestashop docker to an existing mysql server
  • Docker image load failed on mac, error is 'invalid argument'
  • Docker remote api don't restart after my computer restart
  • HEALTHCHECK of a Docker container running Celery tasks?
  • $(pwd) - one level up
  • How do I add :cached or :delegated into a docker-compose.yml volumes list?
  • <html>
    <head>
    </head>
    <body>
    hello index
    </body>
    </html>
    

    but when I look at my domain I see empty page, but looking in page source I see something like this:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    

    It seems Docker is using default Nginx file and takes only part of it (probably the exact length of it as it is in my index.html file. With other files for example abc.html there’s no such issue (probably because it does not exist by default in Nginx image). How can I solve this issue to display correct content of index.html file ?

  • Aurora: Unknown schema in docker parameters
  • Docker volume: backup
  • If docker uses virtual machine to run on a mac then what is its advantage over vagrant?
  • Docker logs not showing colors (express + nodejs image)
  • Unable to start TensorFlow within Docker, on Windows
  • “$ docker build -t docker-whale .” throws an error saying “Some index files failed to download. They have been ignored or old ones used instead.”
  • One Solution collect form web for “Docker – invalid sharing of index.html Nginx file”

    As your volume starts with /c/..., I’m assuming that you’re using the Docker Toolbox on Windows and the docker-machine tool shipped with it. What you’re experiencing is a known issue of Nginx (or rather the sendfile Linux system call that Nginx uses) in conjunction with Virtualbox shared folders.

    This issue is also mentioned in the Vagrant documentation (which also uses VirtualBox), which also comes with a suggested solution that might work for you:

    There is a VirtualBox bug related to sendfile which can result in corrupted or non-updating files. You should deactivate sendfile in any web servers you may be running.

    In Nginx:

    sendfile off;
    

    In Apache:

    EnableSendfile Off
    

    According to the latest comments in the bug report in the vendor bug tracker, if you’re using the open_file_cache directive (disabled by default), you’ll need to turn that off, too:

    open_file_cache off;
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.