Docker Remote API 配置

本文指导如何在Ubuntu/CentOS系统中,通过编辑/etc/default/docker配置文件,永久开启Docker daemon的HTTP接口,从而允许通过浏览器访问并进行Docker API操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

默认情况下,Docker只允许通过unix socket通信操作Docker daemon,但有时我们想通过HTTP调用其Rest API,需单独配置启动参数

 

为了使配置永久生效,在Ubuntu环境下修改其配置文件/etc/default/docker,(centos : /etc/sysconfig/docker) 加入DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:6732",重启Docker服务,可通过浏览器访问设置主机:端口号(6372)/ Docker API操作Docker

 

  1. # Docker Upstart and SysVinit configuration file  
  2.   
  3. # Customize location of Docker binary (especially for development testing).  
  4. #DOCKER="/usr/local/bin/docker"  
  5.   
  6. # Use DOCKER_OPTS to modify the daemon startup options.  
  7. #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"  
  8. DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:6732"  
  9. # If you need Docker to use an HTTP proxy, it can also be specified here.  
  10. #export http_proxy="http://127.0.0.1:3128/"  
  11.   
  12. # This is also a handy place to tweak where Docker's temporary files go.  
  13. #export TMPDIR="/mnt/bigdrive/docker-tmp"  
 

转载于:https://www.cnblogs.com/zhilin-yang/p/4910310.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值