Not getting real file update in vm

I’ve been playing with docker for a while. Recently, I encountered a “bug” that I cannot identify the reason / cause.

I’m currently on windows 8.1 and have docker toolbox installed, which includes docker 1.8.2, docker-machine 0.4.1, and virtualbox 5.0.4 (these are the important ones, presumably). I used to be with pure boot2docker.

  • Migrate container from one machine to another machine
  • Can't install package on alpine though I can see it in the ui
  • Access Cassandra from separate docker container using docker-compose
  • LXC/docker.io & kernel updates
  • gnome-desktop docker image works with Linux Mint Host but not CentOS?
  • Jenkins in docker with access to host docker
  • I’m not really sure about what is going on, so the description could be vague and unhelpful, please ask me for clarification if you need any. Here we go:

    When I write to some files that are located in the shared folders, the vm only gets the file length update, but cannot pick up the new content.

    Let’s use my app.py as an example (I’ve been playing with flask)

    app.py:

    from flask import Flask
    from flask.ext.sqlalchemy import SQLAlchemy
    from werkzeug.contrib.fixers import LighttpdCGIRootFix
    
    import os
    
    app = Flask(__name__)
    app.config.from_object(os.getenv('APP_SETTINGS'))
    app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
    
    db = SQLAlchemy(app)
    
    
    @app.route('/')
    def hello():
        return "My bio!"
    
    
    if __name__ == '__main__':
        app.run(host='0.0.0.0')
    

    and when I cat it in the vm:

    enter image description here

    Now, lets update it to the following, notice the extra exclamation marks:

    from flask import Flask
    from flask.ext.sqlalchemy import SQLAlchemy
    from werkzeug.contrib.fixers import LighttpdCGIRootFix
    
    import os
    
    app = Flask(__name__)
    app.config.from_object(os.getenv('APP_SETTINGS'))
    app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
    
    db = SQLAlchemy(app)
    
    
    @app.route('/')
    def hello():
        return "My bio!!!!!!!"
    
    
    if __name__ == '__main__':
        app.run(host='0.0.0.0')
    

    And when I cat it again:

    enter image description here

    Notice 2 things:

    1. the extra exclamation marks are not there
    2. the EOF sign moved, the number of the spaces, which appeared in front of the EOF sign, is exactly the number of the exclamation marks.

    I suspect that the OS somehow picked up the change in file size, but failed to pick the new content. When I delete characters from the file, the EOF sign also moves, and the cat output is chopped off by exactly how many characters I deleted.

    It’s not only cat that fails to pick up the change, all programs in the vm do. Hence I cannot develop anything when it happens. The changes I make are simply not affecting anything. And I have to kill the vm and spin it up again to get any changes I make, not so efficient.

    Any help will be greatly appreciated! Thank you for reading the long question!

  • How to publish a port different from the default one?
  • com.spotify.docker.client.DockerRequestException: Request error: DELETE unix://localhost:80/v1.12/containers/…: 409
  • Run maven command from docker image
  • Allow nginx to read docker.sock
  • Mounting a network folder to a Docker container in Windows 10
  • Jenkins With Nginx Reverse Proxy And Resolver
  • 2 Solutions collect form web for “Not getting real file update in vm”

    Looks like this is a known issue.

    https://github.com/gliderlabs/pagebuilder/issues/2

    which links to

    https://forums.virtualbox.org/viewtopic.php?f=3&t=33201

    Thanks to Matt Aitchison for replying to my github issue at gliderlabs/docker-alpine

    sync; echo 3 > /proc/sys/vm/drop_caches is the temporary fix.

    A permanent fix doesn’t seem to be coming any time soon…

    I assume that you mounted app.py as a file, using something like

    -v /host/path/to/app.py:/container/path/to/app.py
    

    Sadly, the container will not recognize changes to a file mounted that way.
    Try putting the file in a folder and mount the folder instead. Then changes to that file will be visable in the container.

    Assuming app.py is located in $(pwd)/work, try running the container with

    -v $(pwd)/work:/work
    

    and adjust the command being run to your code as /work/app.py.

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