{"action":"created","issue":{"url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/289","repository_url":"https://api.github.com/repos/khs1994-docker/lnmp","labels_url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/289/labels{/name}","comments_url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/289/comments","events_url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/289/events","html_url":"https://github.com/khs1994-docker/lnmp/issues/289","id":306925737,"number":289,"title":"volumes 中 type: bind 与 HOST:CONTAINER:ro 的区别? 如何把默认的配置映射到主机目录?","user":{"login":"qiuyuhome","id":17526777,"avatar_url":"https://avatars3.githubusercontent.com/u/17526777?v=4","gravatar_id":"","url":"https://api.github.com/users/qiuyuhome","html_url":"https://github.com/qiuyuhome","followers_url":"https://api.github.com/users/qiuyuhome/followers","following_url":"https://api.github.com/users/qiuyuhome/following{/other_user}","gists_url":"https://api.github.com/users/qiuyuhome/gists{/gist_id}","starred_url":"https://api.github.com/users/qiuyuhome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiuyuhome/subscriptions","organizations_url":"https://api.github.com/users/qiuyuhome/orgs","repos_url":"https://api.github.com/users/qiuyuhome/repos","events_url":"https://api.github.com/users/qiuyuhome/events{/privacy}","received_events_url":"https://api.github.com/users/qiuyuhome/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-03-20T15:50:15Z","updated_at":"2018-03-21T02:17:44Z","closed_at":null,"author_association":"NONE","body":"<!--请遵守该模板，不符合规范的问题直接关闭，不予解答-->\r\n\r\n### 操作系统\r\n\r\n<!-- 将你的操作系统保留，其他的删除 -->\r\n\r\n* [x] macOS\r\n\r\n### Docker 版本\r\n\r\n<!--选择一项之后，删除其他选项-->\r\n\r\n* [x] Stable (v17.12)\r\n\r\n### 问题描述\r\n```yaml\r\n    volumes:\r\n      # - ./config/nginx:/etc/nginx/conf.d:ro\r\n      - type: bind\r\n        source: ./config/${NGINX_CONF_D:-nginx}\r\n        target: /etc/nginx/conf.d\r\n      - ./app:${LNMP_PHP_PATH:-/app}\r\n      - ./config/etc/nginx/${NGINX_CONF:-nginx.conf}:/etc/nginx/nginx.conf:ro\r\n      - ./logs/nginx:/var/log/nginx:rw\r\n```\r\n\r\n#### 问题1\r\n\r\n`type: bind` 这中写法, 和 `HOST:CONTAINER:ro` 这种方式, 有什么区别? 为什么要这么写啊? 翻文档. 还是不懂. \r\n\r\n#### 问题2\r\n\r\nnginx 的配置如何能自动的写入到映射的主机目录中. \r\n\r\n例如: nginx 在容器中默认的配置文件, 如何能映射到主机的目录中? \r\n\r\n\r\n\r\n\r\n\r\n<!--提交问题之前务必点击预览（Preview）标签-->\r\n"},"comment":{"url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/comments/374816884","html_url":"https://github.com/khs1994-docker/lnmp/issues/289#issuecomment-374816884","issue_url":"https://api.github.com/repos/khs1994-docker/lnmp/issues/289","id":374816884,"user":{"login":"qiuyuhome","id":17526777,"avatar_url":"https://avatars3.githubusercontent.com/u/17526777?v=4","gravatar_id":"","url":"https://api.github.com/users/qiuyuhome","html_url":"https://github.com/qiuyuhome","followers_url":"https://api.github.com/users/qiuyuhome/followers","following_url":"https://api.github.com/users/qiuyuhome/following{/other_user}","gists_url":"https://api.github.com/users/qiuyuhome/gists{/gist_id}","starred_url":"https://api.github.com/users/qiuyuhome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiuyuhome/subscriptions","organizations_url":"https://api.github.com/users/qiuyuhome/orgs","repos_url":"https://api.github.com/users/qiuyuhome/repos","events_url":"https://api.github.com/users/qiuyuhome/events{/privacy}","received_events_url":"https://api.github.com/users/qiuyuhome/received_events","type":"User","site_admin":false},"created_at":"2018-03-21T02:17:43Z","updated_at":"2018-03-21T02:17:43Z","author_association":"NONE","body":"nginx 容器内的目录:\r\n\r\n```shell\r\nroot@da4b91bccc10:/etc/nginx# pwd\r\n/etc/nginx\r\nroot@da4b91bccc10:/etc/nginx# ls -l\r\ntotal 72\r\ndrwxr-xr-x 17 root root  578 Mar 19 09:34 conf.d\r\n-rw-r--r--  1 root root 1077 Feb 22 10:39 fastcgi.conf\r\n-rw-r--r--  1 root root 1077 Feb 22 10:39 fastcgi.conf.default\r\n-rw-r--r--  1 root root 1007 Feb 22 10:39 fastcgi_params\r\n-rw-r--r--  1 root root 1007 Feb 22 10:39 fastcgi_params.default\r\ndrwxr-xr-x  2 root root 4096 Feb 22 10:39 html\r\n-rw-r--r--  1 root root 2837 Feb 22 10:39 koi-utf\r\n-rw-r--r--  1 root root 2223 Feb 22 10:39 koi-win\r\n-rw-r--r--  1 root root 5170 Feb 22 10:39 mime.types\r\n-rw-r--r--  1 root root 5170 Feb 22 10:39 mime.types.default\r\nlrwxrwxrwx  1 root root   27 Feb 22 10:39 modules -> ../../usr/lib/nginx/modules\r\n-rw-r--r--  1 root root 1477 Mar 19 09:33 nginx.conf\r\n-rw-r--r--  1 root root 2656 Feb 22 10:39 nginx.conf.default\r\n-rw-r--r--  1 root root  636 Feb 22 10:39 scgi_params\r\n-rw-r--r--  1 root root  636 Feb 22 10:39 scgi_params.default\r\n-rw-r--r--  1 root root  664 Feb 22 10:39 uwsgi_params\r\n-rw-r--r--  1 root root  664 Feb 22 10:39 uwsgi_params.default\r\n-rw-r--r--  1 root root 3610 Feb 22 10:39 win-utf\r\n```\r\n\r\n我想把 `/etc/niginx` 下的目录和文件, 都映射到 `./config/etc/nginx_test` 下. \r\n\r\n我试着自己修改了 docker-compse.yaml 文件. \r\n\r\n```yaml\r\n    volumes:\r\n      # - ./config/nginx:/etc/nginx/conf.d:ro\r\n#      - type: bind\r\n#        source: ./config/${NGINX_CONF_D:-nginx}\r\n#        target: /etc/nginx/conf.d\r\n      - ./app:${LNMP_PHP_PATH:-/app}\r\n#      - ./config/etc/nginx/${NGINX_CONF:-nginx.conf}:/etc/nginx/nginx.conf:ro\r\n      - ./logs/nginx:/var/log/nginx:rw\r\n      \r\n      # 这个是测试用的. 上面2个给注释掉了.\r\n      - ./config/etc/nginx_test:/etc/nginx:rw\r\n```\r\n\r\n `./config/etc/nginx` 下现在是没有任何文件的. 所以启动了会报错. \r\n\r\n```shell\r\n➜  lnmp git:(master) ✗ docker-compose up\r\nStarting lnmp_mysql_1 ...\r\nStarting lnmp_phpmyadmin_1 ...\r\nStarting lnmp_redis_1 ...\r\nStarting lnmp_php7_1 ... done\r\nRecreating lnmp_nginx_1 ... done\r\nAttaching to lnmp_phpmyadmin_1, lnmp_mysql_1, lnmp_php7_1, lnmp_redis_1, lnmp_nginx_1\r\nphpmyadmin_1  | 2018-03-21 02:12:21,074 CRIT Supervisor running as root (no user in config file)\r\nphpmyadmin_1  | 2018-03-21 02:12:21,074 WARN Included extra file \"/etc/supervisor.d/nginx.ini\" during parsing\r\nphpmyadmin_1  | 2018-03-21 02:12:21,074 WARN Included extra file \"/etc/supervisor.d/php.ini\" during parsing\r\nphpmyadmin_1  | 2018-03-21 02:12:21,114 INFO RPC interface 'supervisor' initialized\r\nphpmyadmin_1  | 2018-03-21 02:12:21,115 CRIT Server 'unix_http_server' running without any HTTP authentication checking\r\nnginx_1       | nginx: [emerg] open() \"/etc/nginx/nginx.conf\" failed (2: No such file or directory)\r\nphpmyadmin_1  | 2018-03-21 02:12:21,115 INFO supervisord started with pid 1\r\nphpmyadmin_1  | 2018-03-21 02:12:22,117 INFO spawned: 'php-fpm' with pid 13\r\nphpmyadmin_1  | 2018-03-21 02:12:22,118 INFO spawned: 'nginx' with pid 14\r\nphpmyadmin_1  | 2018-03-21 02:12:23,151 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\nphpmyadmin_1  | 2018-03-21 02:12:23,151 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\nlnmp_nginx_1 exited with code 1\r\nnginx_1       | nginx: [emerg] open() \"/etc/nginx/nginx.conf\" failed (2: No such file or directory)\r\n```\r\n\r\n我想实现的目的就是: \r\n\r\n容器中的 `/etc/nginx` 这个目录, 会与 `./config/etc/nginx` 目录文件双向同步. \r\n\r\n而不是挂载. \r\n\r\n不知道这么说你能否明白. \r\n\r\n\r\n"}}
{"actor":{"display_login":"qiuyuhome"}}