Idea:连接Docker服务器

秒速五厘米 2022-10-27 13:47 223阅读 0赞

目录

基础环境

Docker开启远程API

修改docker.service文件

配置生效

重新启动Docker服务

开启2375端口

测试—curl http://192.168.172.128:2375/version

Idea 集成Docker

问题:

idea 底层显示docker窗口


基础环境

Idea: 2019.1.3

Docker: 20.10.2

Centos: 7.8

Docker开启远程API

修改docker.service文件

  1. vim /usr/lib/systemd/system/docker.service

需要修改的部分:

  1. ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

修改后的部分:

  1. ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

配置生效

systemctl daemon-reload

重新启动Docker服务

systemctl stop docker
systemctl start docker

开启2375端口

  1. firewall-cmd --zone=public --add-port=2375/tcp --permanent
  2. firewall-cmd --reload

测试—curl http://192.168.172.128:2375/version

  1. [root@localhost devicemag]# vim /usr/lib/systemd/system/docker.service
  2. [root@localhost devicemag]# systemctl daemon-reload
  3. [root@localhost devicemag]# systemctl stop docker
  4. Warning: Stopping docker.service, but it can still be activated by:
  5. docker.socket
  6. [root@localhost devicemag]# systemctl start docker
  7. [root@localhost devicemag]# curl http://192.168.172.128:2375/version
  8. {"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"20.10.2","Details":{"ApiVersion":"1.41","Arch":"amd64","BuildTime":"2020-12-28T16:16:13.000000000+00:00","Experimental":"false","GitCommit":"8891c58","GoVersion":"go1.13.15","KernelVersion":"3.10.0-1160.el7.x86_64","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"1.4.3","Details":{"GitCommit":"269548fa27e0089a8b8278fc4fc781d7f65a939b"}},{"Name":"runc","Version":"1.0.0-rc92","Details":{"GitCommit":"ff819c7e9184c13b7c2607fe6c30ae19403a7aff"}},{"Name":"docker-init","Version":"0.19.0","Details":{"GitCommit":"de40ad0"}}],"Version":"20.10.2","ApiVersion":"1.41","MinAPIVersion":"1.12","GitCommit":"8891c58","GoVersion":"go1.13.15","Os":"linux","Arch":"amd64","KernelVersion":"3.10.0-1160.el7.x86_64","BuildTime":"2020-12-28T16:16:13.000000000+00:00"}
  9. [root@localhost devicemag]# firewall-cmd --zone=public --add-port=2375/tcp --permanent
  10. success
  11. [root@localhost devicemag]# firewall-cmd --reload

Idea 集成Docker

在IDEA中打开File -> Settings菜单,在插件市场中搜索Docker插件,并安装

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZseTkxMDkwNQ_size_16_color_FFFFFF_t_70 Docker插件

配置连接Docker服务端

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZseTkxMDkwNQ_size_16_color_FFFFFF_t_70 1

连接成功,如下所示

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZseTkxMDkwNQ_size_16_color_FFFFFF_t_70 2

问题:

idea 底层显示docker窗口

IDEA顶部工具栏的View–>Tool Windows–>Docker

/usr/lib/systemd/system/docker.service

  1. [Unit]
  2. Description=Docker Application Container Engine
  3. Documentation=https://docs.docker.com
  4. After=network-online.target firewalld.service containerd.service
  5. Wants=network-online.target
  6. Requires=docker.socket containerd.service
  7. [Service]
  8. Type=notify
  9. # the default is not to use systemd for cgroups because the delegate issues still
  10. # exists and systemd currently does not support the cgroup feature set required
  11. # for containers run by docker
  12. #ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
  13. ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
  14. ExecReload=/bin/kill -s HUP $MAINPID
  15. TimeoutSec=0
  16. RestartSec=2
  17. Restart=always
  18. # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
  19. # Both the old, and new location are accepted by systemd 229 and up, so using the old location
  20. # to make them work for either version of systemd.
  21. StartLimitBurst=3
  22. # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
  23. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
  24. # this option work for either version of systemd.
  25. StartLimitInterval=60s
  26. # Having non-zero Limit*s causes performance problems due to accounting overhead
  27. # in the kernel. We recommend using cgroups to do container-local accounting.
  28. LimitNOFILE=infinity
  29. LimitNPROC=infinity
  30. LimitCORE=infinity
  31. # Comment TasksMax if your systemd version does not support it.
  32. # Only systemd 226 and above support this option.
  33. TasksMax=infinity
  34. # set delegate yes so that systemd does not reset the cgroups of docker containers
  35. Delegate=yes
  36. # kill only the docker process, not all processes in the cgroup
  37. KillMode=process
  38. OOMScoreAdjust=-500
  39. [Install]
  40. WantedBy=multi-user.target

发表评论

表情:
评论列表 (有 0 条评论,223人围观)

还没有评论,来说两句吧...

相关阅读