Napisany przez: JakubBab 22.10.2017, 11:35:16
Cześć,
Host: Windows
Problem: Przegladarka nie wyświetla zmian w pliku. Zmiany które robię na hoscie są przekłądane na kontener i odwrotnie. Po dokonaniu zmian na hoscie przeglądarka nie wyświetla tych zmian tak jakby wcześniejszy index.html był gdzieś cachowany. Jeśli natomiast wejdę do pliku na dockerze , nie zmieniając nic tylko zapisując go (vim :wq) przegladarka to chwyci.
Macie jakiś pomysł wtf?
Docker conf:
Kod
[
{
"Id": "28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd",
"Created": "2017-10-21T21:03:53.189879689Z",
"Path": "nginx",
"Args": [
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 19753,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-10-21T21:03:53.357098671Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:1e5ab59102ce46c277eda5ed77affaa4e3b06a59fe209fe0b05200606db3aa7a",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd/28b704d5f9282840e841147ae2c4604eb642ad0bfa21542278f2702efc54cadd-json.log",
"Name": "/compassionate_kepler",
"RestartCount": 0,
"Driver": "aufs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": [
"5a9dd62adae2ed92f6d8ede9f2066e26ead287241da610fde243c62d0477d9d9",
"0837de95be693b5392d531c614fabd0b22173eae97b91cfd96833a472ff67f77",
"f6367fd59b0f84ff9bc7f0427dabd1bdb625609d492e76ea21c9deb4c2275c4a",
"dd00bf65b35e1984290ed5068fa54442521573d99a183b6ba78ce1759765a046"
],
"HostConfig": {
"Binds": [
"/c/Users/jakub/ProDock:/usr/share/nginx/html"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
28,
172
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [
{
"Type": "bind",
"Source": "/c/Users/jakub/ProDock",
"Destination": "/usr/share/nginx/html",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "28b704d5f928",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"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.13.5-1~stretch",
"NJS_VERSION=1.13.5.0.1.13-1~stretch"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"ArgsEscaped": true,
"Image": "nginx:latest",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "f6ad9aefa25e62e05a0912636f149aaf59a09fdf4996abd0b4bcec3ba3561157",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
]
},
"SandboxKey": "/var/run/docker/netns/f6ad9aefa25e",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "87e096be4be6bb2258e8c7785dd742615fb11b87cf4d412d102c20fc346d0ee9",
"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": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "397f1439dc08e2430245c3359f632f48811705bd03a3eace54a19583ae01e72a",
"EndpointID": "87e096be4be6bb2258e8c7785dd742615fb11b87cf4d412d102c20fc346d0ee9",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
Napisany przez: vokiel 22.10.2017, 11:52:32
Docker compose czy bezpośrednio z obrazu?
Jeśli to pierwsze, to zrób mapowanie volumes do katalogu projektu, np:
version: '2'
services:
php:
build:
context: ./docker/php/
dockerfile: Dockerfile
ports:
- "9000:9000"
volumes_from:
- www
apache:
build:
context: ./docker/apache/
dockerfile: Dockerfile
ports:
- "80:80"
- "443:443"
depends_on:
- php
volumes_from:
- www
www:
image: busybox
volumes:
- .:/var/www/html
W taki sposób operacje na plikach będą widoczne od razu w Dockerze.
Napisany przez: by_ikar 22.10.2017, 12:51:09
@vokiel z info które wrzucił:
Kod
"Mounts": [
{
"Type": "bind",
"Source": "/c/Users/jakub/ProDock",
"Destination": "/usr/share/nginx/html",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
]
to ma podpięty volumen.
Tutaj problem jest inny, może nim być ograniczenie dockera pod windowsem: https://docs.docker.com/docker-for-windows/troubleshoot/#inotify-on-shared-drives-does-not-work lub coś innego. Dla testu,
@JakubBab spróbuj swoją stronę odpalić w chrome, ale otwórz narzędzia developerskie i w sekcji "network" zaznacz "disable cache"; następnie dokonaj jakiejś zmiany i odśwież stronę (mając wciąż otwarte narzędzia developerskie).
Jeżeli zobaczysz zmianę, winne są nagłówki (ich brak), przez które przeglądarka dość mocno cachuje pliki statyczne. Dodanie do konfiguracji nginxa w sekcji "server" parametru "expires -1h;" powinno rozwiązać twój problem. Więcej informacji o expires: http://nginx.org/en/docs/http/ngx_http_headers_module.html#expires