This is on OS X 10.9 with Boot2Docker 1.6.2 (using AUFS) and Docker 1.6.2. Running the Nginx container with a volume for static files produces garbage.
docker run -v "$(pwd)/html:/usr/share/nginx/html" -p 80:80 -d nginx
html/index.html was originally (when I started the container):
Then I changed it to:
I have a different length than you think!
This has 42 bytes, including the trailing newline. When I use any browser to access this container, I get the original file content (padded with zero bytes), but the Content-Length matches the new version: (I'm using dnsmasq to map all *.docker domains to the Boot2Docker IP.)
felix-mba:funk fr$ curl -v http://garbage.docker/
* Adding handle: conn: 0x7f9d4a803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f9d4a803a00) send_pipe: 1, recv_pipe: 0
* About to connect() to garbage.docker port 80 (#0)
* Trying 192.168.59.103...
* Connected to garbage.docker (192.168.59.103) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: garbage.docker
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.9.0 is not blacklisted
< Server: nginx/1.9.0
< Date: Fri, 22 May 2015 18:21:55 GMT
< Content-Type: text/html
< Content-Length: 42
< Last-Modified: Fri, 22 May 2015 18:21:54 GMT
< Connection: keep-alive
< ETag: "555f73c2-2a"
< Accept-Ranges: bytes
<
Hey
* Connection #0 to host garbage.docker left intact
felix-mba:funk fr$ curl -s http://garbage.docker/ | hexdump -C
00000000 48 65 79 0a 00 00 00 00 00 00 00 00 00 00 00 00 |Hey.............|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 |..........|
0000002a
felix-mba:funk fr$
Any ideas?
felix-mba:funk fr$ hexdump -C html/index.html
00000000 49 20 68 61 76 65 20 61 20 64 69 66 66 65 72 65 |I have a differe|
00000010 6e 74 20 6c 65 6e 67 74 68 20 74 68 61 6e 20 79 |nt length than y|
00000020 6f 75 20 74 68 69 6e 6b 21 0a |ou think!.|
0000002a
felix-mba:funk fr$
See also https://github.com/boot2docker/boot2docker/issues/652. This seems to be a VirtualBox bug.
Yeah, the first thing to try would be to reproduce the effect on a real machine.
The workaround I use is to set sendfile off. (Another might be to use NFS, as described in https://github.com/boot2docker/boot2docker/issues/652#issuecomment-97609770, but I have not tested this myself.)
Dockerfile:
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
nginx.conf: (just commented out the sendfile on; line)
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
#sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Closing as this is clearly reported to be a VirtualBox bug.
First, thanks! But I have a question:
How to disable PHP caching when running PHP using Docker?
When I modify the Index.php I don't see my change.
+1 to using sendfile off in nginx - saved me a ton of time getting this to work with Docker Toolbox on Windows 10
Most helpful comment
The workaround I use is to set
sendfile off. (Another might be to use NFS, as described in https://github.com/boot2docker/boot2docker/issues/652#issuecomment-97609770, but I have not tested this myself.)Dockerfile:
nginx.conf: (just commented out the
sendfile on;line)Closing as this is clearly reported to be a VirtualBox bug.