一、配置开启Docker远程连接

首先需要安装docker,参考我这篇文章:基于CentOS7安装配置docker与docker-compose

配置开启Docker远程连接的步骤:

//1-编辑/usr/lib/systemd/system/docker.service 文件

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

//2-找到ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock这一行,

//在后面增加内容,记得先打一个空格。后面增加-H tcp://0.0.0.0:2375

//docker连接端口为2375

//即ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375

//重新加载

systemctl daemon-reload

//重启docker

systemctl restart docker

或者直接 systemctl daemon-reload && systemctl restart docker

1-编辑/usr/lib/systemd/system/docker.service 文件: 配置完成后完整的docekr.service:

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target docker.socket firewalld.service containerd.service time-set.target

Wants=network-online.target containerd.service

Requires=docker.socket

[Service]

Type=notify

# the default is not to use systemd for cgroups because the delegate issues still

# exists and systemd currently does not support the cgroup feature set required

# for containers run by docker

# 2023-11-8 22:44:37 add -H tcp://0.0.0.0:2375 DJCKING

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375

ExecReload=/bin/kill -s HUP $MAINPID

TimeoutStartSec=0

RestartSec=2

Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.

# Both the old, and new location are accepted by systemd 229 and up, so using the old location

# to make them work for either version of systemd.

StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.

# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make

# this option work for either version of systemd.

StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead

# in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.

# Only systemd 226 and above support this option.

TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

# kill only the docker process, not all processes in the cgroup

KillMode=process

OOMScoreAdjust=-500

[Install]

WantedBy=multi-user.target

systemctl daemon-reload 与systemctl restart docker: systemctl status docker:查看docker状态(后面增加的内容 -H tcp://0.0.0.0:2375 也有了)

二、在IDEA中配置Docker远程连接

/usr/lib/systemd/system/这个文件夹里都是一些system的服务,例如firewalld.service、docker.service等。

三、Docker 未授权访问漏洞

引用来自:未授权访问漏洞中的Docker 未授权访问

如果在docker上配置了远程访问,docker 节点上会开放一个TCP端口2375,绑定在0.0.0.0上,如果没有做限制的话,攻击者就可以通过Docker未授权来控制服务器。

下列引用来自:Docker——docker安全、Docker remote api 访问控制、TLS加密通讯

作为一款应用 Docker 本身实现上会有代码缺陷。CVE官方记录Docker历史版本共有超过20项漏洞。黑客常用的攻击手段主要有代码执行、权限提升、 信息泄露、权限绕过等。目前 Docker 版本更迭非常快,Docker 用户最好将 Docker 升级为 最新版本。

Docker 提供了 Docker hub,可以让用户上传创建的镜像,以便其他用户下载,快速搭 建环境。但同时也带来了一些安全问题。 例如下面三种方式: (1)黑客上传恶意镜像 如果有黑客在制作的镜像中植入木马、后门等恶意软件,那么环境从一开始就已经不安全了,后续更没有什么安全可言。 (2)镜像使用有漏洞的软件 Docker Hub 上能下载的镜像里面,75%的镜像都安装了有漏洞的软件。所以下载镜像后,需要检查里面软件的版本信息,对应的版本是否存在漏洞,并及时更新打上补丁。 (3)中间人攻击篡改镜像 镜像在传输过程中可能被篡改,目前新版本的 Docker 已经提供了相应的校验机制来预 防这个问题。

docker stop 容器-停止容器-多了一个Ubuntu18.04的镜像(不是本人下载的,开启docker远程连接后,莫名奇妙出现了ubuntu:18.04的镜像)-可能为黑客恶意利用docker远程连接漏洞(初次开启docker远程连接,没有配置证书加密),在服务器上docker跑的矿机程序。 相关内容: 阿里云docker容器会自动运行ubuntu容器??我并没有下载这个镜像 阿里云docker容器会自动运行ubuntu容器??

enbash.tar:恶意文件。

docker exec -it 容器的Names或者ID 表示 进入容器: -i: 交互式操作。 -t: 终端。 /bin/bash:放在镜像名后的是命令,这里我们希望有个交互式 Shell,因此用的是 /bin/bash。 退出终端:直接输入 exit。 先停止再删除容器-最后删除镜像:

四、解决Docker 未授权访问漏洞

解决细节:后续补充(2023-11-12 22:43:14)

五、相关参考文章

基于CentOS7安装配置docker与docker-compose 【Docker】1、Centos安装Docker服务 【Docker】11、IDEA集成Docker插件实现一键部署SpringBoot项目 Docker 配置SSL证书加密远程链接 Remote/Rest API 长文详解!Docker客户端与服务端TLS认证(Docker Remote API认证) Docker——docker安全、Docker remote api 访问控制、TLS加密通讯 Docker 容器使用 未授权访问漏洞 Linux 入侵痕迹清理技巧 linux 系统痕迹命令(详细总结) 2023-11-12 20:46:40

参考阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: