栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

配置Docker守护程序端口以启用Docker API

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

配置Docker守护程序端口以启用Docker API

这是Dan Low提供的答案的补充。

配置Docker守护程序端口有两种方法:

  1. / etc / default / docker 文件中配置:

    DOCKER_OPTS="-H tcp://127.0.0.1:5000 -H unix:///var/run/docker.sock"
  2. /etc/docker/daemon.json中 配置:

    {

    “debug”: true,
    “hosts”: [“tcp://127.0.0.1:5000”, “unix:///var/run/docker.sock”]
    }

配置端口后,重新启动Docker服务。

如果未配置Docker默认套接字,则可能会出现问题中提到的类似问题,即 Docker将等待无限期

注意:但不要同时在 两个 配置文件中进行配置。可能会发生以下错误:

Waiting for /var/run/docker.sockunable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [tcp://127.0.0.1:5000 unix:///var/run/docker.sock], from file: tcp://127.0.0.1:5000)

其原因将两个的 用户端口[TCP://127.0.0.1:5000]
默认多克尔插座[UNIX:///var/run/docker.sock] 是用户端口使得接入到 多克尔的API
而默认套接字启用CLI。如果

/etc/default/docker
文件中未提及默认端口[unix:///var/run/docker.sock],则可能会发生以下错误:

# docker psCannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

该错误不是因为Docker容器未运行,而是因为未启用默认Docker套接字。

这适用于Docker 17.04版本,并且可能因不同版本的Docker而有所不同。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372250.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号