Centos7 开启 Docker API 接口

文章描述

Centos7 开启 Docker API 接口

# Centos7 开启 Docker API 接口
### 1、修改配置
````shell
sudo vim /lib/systemd/system/docker.service
````
> 找到 `ExecStart`增加 `-H tcp://0.0.0.0:2375 `
```shell
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
```
````shell
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock
````
### 2、重启Docker
```shell
sudo systemctl daemon-reload
sudo systemctl restart docker
```
### 3、验证结果
```shell
netstat -nutlp | grep 2375
```
### 4、查看API版本
> `docker version`
````shell
Client: Docker Engine - Community
Version: 20.10.12
API version: 1.41
Go version: go1.16.12
Git commit: e91ed57
Built: Mon Dec 13 11:45:41 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.12
API version: 1.41 (minimum version 1.12)
Go version: go1.16.12
Git commit: 459d0df
Built: Mon Dec 13 11:44:05 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.13
GitCommit: 9cc61520f4cd876b86e77edfeb88fbcd536d1f9d
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
````

 

## 后续,增加Python使用

评论(共0条)