idea连接linux远程docker详细教程操作

1:修改docker配置文件docker.service

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

2:找到 ExecStart,在最后面添加 -H tcp://0.0.0.0:2375

# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

3:开放系统端口

3-1:关闭防火墙

systemctl stop firewalld

3-2:防火墙开放端口

添加 --permanent永久生效,没有此参数重启后失效

firewall-cmd --zone=public --add-port=2375/tcp --permanent

重新载入

firewall-cmd --reload

查看所有打开的端口:

firewall-cmd --zone=public --list-ports

4:重启docker

4-1:如果docker启动了执行命令

[root@localhost ~]# systemctl stop docker.socket

4-2:执行启动命令

[root@localhost ~]# systemctl daemon-reload && systemctl start docker

4-3:通过docker启动状态可以查看是否读取了配置文件和开启了监听2375端口

[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 二 2023-08-22 17:46:00 CST; 14s ago
     Docs: https://docs.docker.com
 Main PID: 8219 (dockerd)
    Tasks: 7
   Memory: 24.3M
   CGroup: /system.slice/docker.service
           └─8219 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375

822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.266423902+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.290199031+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.308690375+08:00" level=info msg="Loading containers: start."
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.499669329+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0...IP address"
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.527983877+08:00" level=info msg="Loading containers: done."
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.562405494+08:00" level=info msg="Docker daemon" commit=3056208 graphdriver(s)=overlay2 version=20.10.21
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.562786361+08:00" level=info msg="Daemon has completed initialization"
822 17:46:00 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.601480387+08:00" level=info msg="API listen on /var/run/docker.sock"
822 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.602129704+08:00" level=info msg="API listen on [::]:2375"
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# 

4-4:通过curl http://docker宿主机IP:2375/version验证是否可以远程连接docker

[root@localhost ~]# curl http://192.168.11.48:2375/version
{"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"20.10.21","Details":{"ApiVersion":"1.41","Arch":"amd64","BuildTime":"2022-10-25T18:02:38.000000000+00ommit":"3056208","GoVersion":"go1.18.7","KernelVersion":"3.10.0-1160.el7.x86_64","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"1.6.10","Details":{"GitCommit":"770bd0108},{"Name":"runc","Version":"1.1.4","Details":{"GitCommit":"v1.1.4-0-g5fd4c4d"}},{"Name":"docker-init","Version":"0.19.0","Details":{"GitCommit":"de40ad0"}}],"Version":"20.10.21","ApiVersion":"Commit":"3056208","GoVersion":"go1.18.7","Os":"linux","Arch":"amd64","KernelVersion":"3.10.0-1160.el7.x86_64","BuildTime":"2022-10-25T18:02:38.000000000+00:00"}
[root@localhost ~]# 

5:windows如果无法远程连接Docker,需要把以下服务都启动

idea连接linux远程docker详细教程操作_第1张图片

6:idea配置远程docker服务

1:在idea的Settings搜索输入docker(前提idea必须安装了docker插件)
2:点击docker
3:点击“+”
4:输入docker服务名字(自定义)
5:选择TCP socket然后输入tcp://docker宿主机IP:2375
6:连接docker服务状态为成功

![在这里插入图片描述](https://img-blog.csdnimg.cn/8c04fb8f529b4347acd14cf54e75b239.pngidea连接linux远程docker详细教程操作_第2张图片

7:idea连接docker服务进行启动

1:点击服务services

2:选择需要启动的远程docker服务(可以配置连接多个ddocker服务)

3:点击启动服务

idea连接linux远程docker详细教程操作_第3张图片

8:idea连接docker服务进行生成镜像

idea连接linux远程docker详细教程操作_第4张图片

1:如出现提示连接不上是和docker服务连接断开了

idea连接linux远程docker详细教程操作_第5张图片

2:需要点击docker服务停止再点击启动

idea连接linux远程docker详细教程操作_第6张图片

9:通过idea拉去线上镜像

1:选择需要操作docker服务下的images

2:输入需要拉去的镜像名字和版本,例如nginx

3:点击pull,就会自动拉去镜像直至完成

idea连接linux远程docker详细教程操作_第7张图片

10:对镜像可以删除,查看镜像配置操作和创建容器

idea连接linux远程docker详细教程操作_第8张图片

10-1:创建poi容器方法一:点击上图2 Create Container去创建

idea连接linux远程docker详细教程操作_第9张图片

10-2:创建poi容器方法二:点击edit Configurations

idea连接linux远程docker详细教程操作_第10张图片

10-3:创建poi容器的时候添加配置端口,挂载等

idea连接linux远程docker详细教程操作_第11张图片

11:启动和操作容器

idea连接linux远程docker详细教程操作_第12张图片

11-1:查看容器创建过程

idea连接linux远程docker详细教程操作_第13张图片

11-2:查看容器日记,重启容器,停止容器,进入容器终端

idea连接linux远程docker详细教程操作_第14张图片

11-3:查看容器仪表盘

idea连接linux远程docker详细教程操作_第15张图片

12:全部创建的容器配置,镜像配置,编排配置可以修改和删除

idea连接linux远程docker详细教程操作_第16张图片

13:如何创建的容器配置,镜像配置,编排配置

idea连接linux远程docker详细教程操作_第17张图片

你可能感兴趣的:(intellij-idea,linux,docker)