Liunx Ubuntu Server 安装配置 Docker

1. 安装Docker

1.1 更新软件包列表
shell 复制代码
sudo apt update
1.2 添加Docker存储库
shell 复制代码
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
1.3 再次更新软件包列表,以使系统能够访问Docker软件包
shell 复制代码
sudo apt update
1.4 安装Docker引擎
shell 复制代码
sudo apt install docker-ce docker-ce-cli containerd.io
1.5 启动Docker
shell 复制代码
sudo systemctl status docker

2. 创建Docker用户组

在Ubuntu上安装Docker后,默认情况下只有root用户和拥有sudo权限的用户可以直接运行Docker命令。如果你想将其他用户添加到Docker用户组中,使其能够无需sudo权限来运行Docker命令

2.1 创建用户组
shell 复制代码
sudo groupadd docker
2.2 将用户添加进用户组
shell 复制代码
sudo usermod -aG docker $USER
2.3 更新用户组更改
shell 复制代码
newgrp docker
2.4 验证用户组更改是否成功
shell 复制代码
docker run hello-world

3. 开启Docker2375端口

在Docker中开放端口2375意味着允许远程连接到Docker守护程序,这样可以通过网络连接来管理Docker守护程序,这可能会带来安全风险,通过服务器防火墙安全组来控制ip访问。

3.1 编辑Docker守护程序配置文件
shell 复制代码
sudo nano /etc/docker/daemon.json
3.2 在配置文件中添加以下内容
json 复制代码
{
  "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}
3.3 重启Docker服务
shell 复制代码
sudo systemctl restart docker
相关推荐
程序员老赵8 小时前
10 分钟部署 OpenCode:Docker 一键安装,浏览器打开就能用 AI 写代码(附完整命令与排错)
docker·容器·ai编程
WangMingHua11112 小时前
LM Studio Docker 部署——本地大模型一键启动
docker
曲幽2 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
武子康3 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple
Alsn866 天前
等待学习-学习目录:Docker 容器安全攻防
学习·安全·docker
张飞飞飞飞飞7 天前
Tmux命令使用教程
linux·服务器·ubuntu
程序员老赵7 天前
服务器没有桌面?Docker 跑个 Chrome,浏览器就能远程用
docker·容器·devops
杨浦老苏7 天前
轻量级Docker仪表板Servedash
运维·docker·监控·群晖·仪表板
正经教主7 天前
【docker基础】 第八周:容器监控与应用更新策略
运维·docker·容器
kiros_wang7 天前
Docker 使用完整指南
运维·docker·容器