1

我正在尝试按照本指南在 Docker 上设置 Elasticsearch 集群:https ://sematext.com/blog/2016/12/12/docker-elasticsearch-swarm/

但是在创建 jwilder/nginx-proxy 服务后,我一直收到关于 /tmp/docker.sock 的错误。下面的控制台截图来自新安装和更新的 CentOS7。我按照此处的说明通过 yum 安装了 docker:https ://docs.docker.com/engine/installation/linux/centos/

[root@centos7]# docker -v
Docker version 1.13.1, build 092cba3
[root@centos7]#
[root@centos7]# docker service create --mode global \
> --name proxy -p 80:80 \
> --network elasticsearch-frontend \
> --network elasticsearch-backend  \
> --mount type=bind,bind-propagation=rshared,src=/var/run/docker.sock,target=/tmp/docker.sock:ro \
> jwilder/nginx-proxy
xbhj4rzjyuu0k8maf1ha5fmgs
[root@centos7]# docker service ls
ID            NAME   MODE    REPLICAS  IMAGE
xbhj4rzjyuu0  proxy  global  0/1       jwilder/nginx-proxy:latest
[root@centos7]# docker ps -a
CONTAINER ID        IMAGE                                                                                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
7ba303e0f8b6        jwilder/nginx-proxy@sha256:9a2d63aad9068f817c705965f41f2f32fa0bbef6b217ae5c9b2340ef23e3dcba   "/app/docker-entry..."   2 seconds ago       Created                                         proxy.kifcc5gbdcxz5ixsbx7sl1cv8.zuizhtt7q94nluuudlgjgy1yi
2fe655a93aa4        jwilder/nginx-proxy@sha256:9a2d63aad9068f817c705965f41f2f32fa0bbef6b217ae5c9b2340ef23e3dcba   "/app/docker-entry..."   10 seconds ago      Exited (1) 3 seconds ago                        proxy.kifcc5gbdcxz5ixsbx7sl1cv8.baqn1204spbw5v6qxx6qjx327
7894fd0e1dee        jwilder/nginx-proxy@sha256:9a2d63aad9068f817c705965f41f2f32fa0bbef6b217ae5c9b2340ef23e3dcba   "/app/docker-entry..."   18 seconds ago      Exited (1) 11 seconds ago                       proxy.kifcc5gbdcxz5ixsbx7sl1cv8.6s9u0q0y1kjelebszheius2es
51840cca0d32        jwilder/nginx-proxy@sha256:9a2d63aad9068f817c705965f41f2f32fa0bbef6b217ae5c9b2340ef23e3dcba   "/app/docker-entry..."   26 seconds ago      Exited (1) 19 seconds ago                       proxy.kifcc5gbdcxz5ixsbx7sl1cv8.wlwy723ts9kw00sgyu3s5f985
d52fd18567a9        jwilder/nginx-proxy@sha256:9a2d63aad9068f817c705965f41f2f32fa0bbef6b217ae5c9b2340ef23e3dcba   "/app/docker-entry..."   34 seconds ago      Exited (1) 27 seconds ago                       proxy.kifcc5gbdcxz5ixsbx7sl1cv8.wa5jk9xnly1tdxpbvonnjmoty
[root@centos7]# docker logs 2fe655a93aa4
ERROR: you need to share your Docker host socket with a volume at /tmp/docker.sock
Typically you should run your jwilder/nginx-proxy with: `-v /var/run/docker.sock:/tmp/docker.sock:ro`
See the documentation at http://git.io/vZaGJ
[root@centos7]#

jwilder/nginx-proxy 容器在作为单个容器启动时工作,使用 -v 选项挂载 docker.sock。

我已经搜索了谷歌(Docker 文档、jwilder/nginx-proxy git)寻找会导致这种情况的原因,但我什么也没想到。有人看出什么不对了吗?我是码头工人的新手,所以也许我错过了一些简单的东西。

提前致谢!:-)

4

1 回答 1

1

不是对 to 进行只读挂载,而是对/var/run/docker.sockto/tmp/docker.sock进行挂载/var/run/docker.sock/tmp/docker.sock:ro因此应用程序会哭泣。

要纠正这一点,请稍作修改。代替...

--mount type=bind,bind-propagation=rshared,src=/var/run/docker.sock,target=/tmp/docker.sock:ro

...和:

--mount type=bind,bind-propagation=rshared,src=/var/run/docker.sock,target=/tmp/docker.sock,ro=1

文档中:

readonly 或 ro:引擎挂载绑定和卷读写,除非在挂载绑定或卷时给出只读选项。当 true 或 1 或没有值时,绑定或卷以只读方式安装。当 false 或 0 时,绑定或卷以读写方式安装。

于 2017-02-11T08:58:38.303 回答