安装docker插件
image.png
开放docker api 实现远程访问
- 修改/etc/sysconfig/docker文件,在最后增加一行DOCKER_OPTS,表明开放端口5555用作远程操作
# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
DOCKER_OPTS="-H unix:///var/run/docker.sock -H 0.0.0.0:5555"
- 修改/usr/lib/systemd/system/docker.service
vim /usr/lib/systemd/system/docker.service
在[Service]的ExexStart=下面增加一行$DOCKER_OPTS
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$DOCKER_OPTS \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
- 用curl测试
curl -v -X GET 主机ip:5555/images/json |python -m json.tool
在IDEA中配置
-
image.png
常见问题
网友评论