简体   繁体   中英

Docker 1.9 volumes not updating on Mac OS. Image nginx

I'm trying to run a simple web application on a docker container. I want to mount a volume on the container which is dynamically updated with the content on my MacOs folder specified.

It works when adding and removing files, but when I add some stuff to a file and save it I cannot see the content updated on the container.

Any idea what is happening?

Docker & Docker-machine versions:

docker-machine version 0.5.1 (7e8e38e)
docDocker version 1.9.1, build a34a1d5

Command I run to create the container:

docker run --name foo-nginx -v $PWD:/usr/share/nginx/html:ro -d -p 8080:80 nginx

Docker inspect container:

[{
"Id": "385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336",
"Created": "2015-11-23T16:18:32.120393359Z",
"Path": "nginx",
"Args": [
    "-g",
    "daemon off;"
],
"State": {
    "Status": "running",
    "Running": true,
    "Paused": false,
    "Restarting": false,
    "OOMKilled": false,
    "Dead": false,
    "Pid": 1398,
    "ExitCode": 0,
    "Error": "",
    "StartedAt": "2015-11-23T16:21:03.511426525Z",
    "FinishedAt": "2015-11-23T16:21:03.080734898Z"
},
"Image": "9fab4090484a840de49347c9c49597ab32df23ec26bb98d7a7ec24d59dff8945",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336/385c6fcd0184476cc3b1dc95faac3763770785032284307f7a88f9b666137336-json.log",
"Name": "/foo-nginx",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
    "Binds": [
        "/Users/gobeltri/workspace/foo-docker:/usr/share/nginx/html:ro"
    ],
    "ContainerIDFile": "",
    "LxcConf": [],
    "Memory": 0,
    "MemoryReservation": 0,
    "MemorySwap": 0,
    "KernelMemory": 0,
    "CpuShares": 0,
    "CpuPeriod": 0,
    "CpusetCpus": "",
    "CpusetMems": "",
    "CpuQuota": 0,
    "BlkioWeight": 0,
    "OomKillDisable": false,
    "MemorySwappiness": -1,
    "Privileged": false,
    "PortBindings": {
        "80/tcp": [
            {
                "HostIp": "",
                "HostPort": "8080"
            }
        ]
    },
    "Links": null,
    "PublishAllPorts": false,
    "Dns": [],
    "DnsOptions": [],
    "DnsSearch": [],
    "ExtraHosts": null,
    "VolumesFrom": null,
    "Devices": [],
    "NetworkMode": "default",
    "IpcMode": "",
    "PidMode": "",
    "UTSMode": "",
    "CapAdd": null,
    "CapDrop": null,
    "GroupAdd": null,
    "RestartPolicy": {
        "Name": "no",
        "MaximumRetryCount": 0
    },
    "SecurityOpt": null,
    "ReadonlyRootfs": false,
    "Ulimits": null,
    "LogConfig": {
        "Type": "json-file",
        "Config": {}
    },
    "CgroupParent": "",
    "ConsoleSize": [
        0,
        0
    ],
    "VolumeDriver": ""
},
"GraphDriver": {
    "Name": "aufs",
    "Data": null
},
"Mounts": [
    {
        "Source": "/Users/gobeltri/workspace/foo-docker",
        "Destination": "/usr/share/nginx/html",
        "Mode": "ro",
        "RW": false
    },
    {
        "Name": "737d1c59dc872f72530b54b80408292190453416c3768e4183ffab830a479878",
        "Source": "/mnt/sda1/var/lib/docker/volumes/737d1c59dc872f72530b54b80408292190453416c3768e4183ffab830a479878/_data",
        "Destination": "/var/cache/nginx",
        "Driver": "local",
        "Mode": "",
        "RW": true
    }
],
"Config": {
    "Hostname": "385c6fcd0184",
    "Domainname": "",
    "User": "",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "ExposedPorts": {
        "443/tcp": {},
        "80/tcp": {}
    },
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": [
        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "NGINX_VERSION=1.9.7-1~jessie"
    ],
    "Cmd": [
        "nginx",
        "-g",
        "daemon off;"
    ],
    "Image": "nginx",
    "Volumes": {
        "/var/cache/nginx": {}
    },
    "WorkingDir": "",
    "Entrypoint": null,
    "OnBuild": null,
    "Labels": {},
    "StopSignal": "SIGTERM"
},
"NetworkSettings": {
    "Bridge": "",
    "SandboxID": "749ea24857714fbdbb3390fc6e1bd21590f88f2b39b3a2acf176362cbe9bedcc",
    "HairpinMode": false,
    "LinkLocalIPv6Address": "",
    "LinkLocalIPv6PrefixLen": 0,
    "Ports": {
        "443/tcp": null,
        "80/tcp": [
            {
                "HostIp": "0.0.0.0",
                "HostPort": "8080"
            }
        ]
    },
    "SandboxKey": "/var/run/docker/netns/749ea2485771",
    "SecondaryIPAddresses": null,
    "SecondaryIPv6Addresses": null,
    "EndpointID": "2e64b98990ce42c3e5ec5c8d3fb55a759e96c0994d31003139856e2f628084a4",
    "Gateway": "172.17.0.1",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "IPAddress": "172.17.0.2",
    "IPPrefixLen": 16,
    "IPv6Gateway": "",
    "MacAddress": "02:42:ac:11:00:02",
    "Networks": {
        "bridge": {
            "EndpointID": "2e64b98990ce42c3e5ec5c8d3fb55a759e96c0994d31003139856e2f628084a4",
            "Gateway": "172.17.0.1",
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "MacAddress": "02:42:ac:11:00:02"
        }
    }
}

} ]

Turning off sendfile off for Nginx solved this issue.

sendfile off;

see also:
https://github.com/docker/docker/issues/15793 https://abitwiser.wordpress.com/2011/02/24/virtualbox-hates-sendfile/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM