1:修改docker配置文件docker.service
bash
复制代码
vi /usr/lib/systemd/system/docker.service
2:找到 ExecStart,在最后面添加 -H tcp://0.0.0.0:2375
bash
复制代码
# 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:关闭防火墙
bash
复制代码
systemctl stop firewalld
3-2:防火墙开放端口
添加 --permanent永久生效,没有此参数重启后失效
bash
复制代码
firewall-cmd --zone=public --add-port=2375/tcp --permanent
重新载入
bash
复制代码
firewall-cmd --reload
查看所有打开的端口:
bash
复制代码
firewall-cmd --zone=public --list-ports
4:重启docker
4-1:如果docker启动了执行命令
lua
复制代码
[root@localhost ~]# systemctl stop docker.socket
4-2:执行启动命令
lua
复制代码
[root@localhost ~]# systemctl daemon-reload && systemctl start docker
4-3:通过docker启动状态可以查看是否读取了配置文件和开启了监听2375端口
lua
复制代码
[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
8月 22 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
8月 22 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"
8月 22 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.308690375+08:00" level=info msg="Loading containers: start."
8月 22 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"
8月 22 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.527983877+08:00" level=info msg="Loading containers: done."
8月 22 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
8月 22 17:46:00 localhost.localdomain dockerd[8219]: time="2023-08-22T17:46:00.562786361+08:00" level=info msg="Daemon has completed initialization"
8月 22 17:46:00 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
8月 22 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"
8月 22 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 ~]#
lua
复制代码
[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,需要把以下服务都启动
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.png![在这里插入图片描述](https://file.jishuzhan.net/article/1694187849600995329/974d625f129c41b2a2e3ef84f4cfc455.png)
7:idea连接docker服务进行启动
1:点击服务services
2:选择需要启动的远程docker服务(可以配置连接多个ddocker服务)
3:点击启动服务
8:idea连接docker服务进行生成镜像
1:如出现提示连接不上是和docker服务连接断开了
2:需要点击docker服务停止再点击启动
9:通过idea拉去线上镜像
1:选择需要操作docker服务下的images
2:输入需要拉去的镜像名字和版本,例如nginx
3:点击pull,就会自动拉去镜像直至完成
10:对镜像可以删除,查看镜像配置操作和创建容器
10-1:创建poi容器方法一:点击上图2 Create Container去创建
10-2:创建poi容器方法二:点击edit Configurations
10-3:创建poi容器的时候添加配置端口,挂载等
11:启动和操作容器
11-1:查看容器创建过程
11-2:查看容器日记,重启容器,停止容器,进入容器终端
11-3:查看容器仪表盘
12:全部创建的容器配置,镜像配置,编排配置可以修改和删除
13:如何创建的容器配置,镜像配置,编排配置