我很确定它曾经以这种方式工作,但现在我不能让它工作了......这就是问题所在:
$ docker run -d -p 80:80 --name frontend -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf -v $(pwd)/htpasswd:/htpasswd nginx
我想要在主机中编辑这个nginx.conf
文件,然后运行
$ docker exec -ti frontend nginx -s reload
让我的前端服务器重新加载。但我无法从容器内部看到nginx.conf
的变化。那是为什么?
如果这有帮助:
[
{
"Id": "39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60",
"Created": "2016-07-07T18:59:35.917569545Z",
"Path": "nginx",
"Args": [
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 17786,
"ExitCode": 0,
"Error": "",
"StartedAt": "2016-07-07T18:59:36.241298894Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470d",
"ResolvConfPath": "/var/lib/docker/containers/39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60/hostname",
"HostsPath": "/var/lib/docker/containers/39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60/hosts",
"LogPath": "/var/lib/docker/containers/39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60/39ceafd41f7576638d4b129ea90b0522aa61f25d62e68e361de905638ba74f60-json.log",
"Name": "/frontend",
"RestartCount": 0,
"Driver": "devicemapper",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/jpmelos/nginx.conf:/etc/nginx/nginx.conf",
"/home/jpmelos/htpasswd:/htpasswd"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "infra",
"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": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"StorageOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"BlkioIOps": 0,
"BlkioBps": 0,
"SandboxSize": 0
},
"GraphDriver": {
"Name": "devicemapper",
"Data": {
"DeviceId": "3660",
"DeviceName": "docker-253:0-3147678-71e674d2c1754f73d3fdd933a1971bf8464f6aa6b738dc818a668beb96a4e6ea",
"DeviceSize": "10737418240"
}
},
"Mounts": [
{
"Source": "/home/jpmelos/nginx.conf",
"Destination": "/etc/nginx/nginx.conf",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Source": "/home/jpmelos/htpasswd",
"Destination": "/htpasswd",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "39ceafd41f75",
"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.11.1-1~jessie"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "nginx",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c20b1912f3689cf6b82d19b2ae3173e050b3958e266dd19dd047aeccacabef55",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": null,
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
]
},
"SandboxKey": "/var/run/docker/netns/c20b1912f368",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"infra": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "4598916660ed5453a5ec48412452b00ef6dce24f64b5e315b625596a806442c1",
"EndpointID": "9e7d50cdfbdcec31331655b167ec0e6c5ee20b6e3cc7122222706f99418732d2",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02"
}
}
}
}
]
有趣的位:Mounts
部分表示挂载点为rprivate
。这可能是问题,但我研究过,我找不到任何关于它的东西......
答案 0 :(得分:0)
看起来答案是Docker不允许编辑共享文件,只允许编辑共享目录中的文件。当我将配置文件放在共享目录中并将其包含在nginx.conf
中时,它就完成了。