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
相关推荐
JAVA学习通16 分钟前
发布自己的 jar 包到 Maven 中央仓库 ( mvnrepository.com )
人工智能·docker·自然语言处理·容器·rocketmq
周之鸥2 小时前
从零部署 Astro 静态网站到云服务器(含 HTTPS 一键配置)
运维·服务器·ubuntu·http·https·astro
木亦汐丫3 小时前
Docker 镜像版本Alpine、Slim、Bookworm、Bullseye、Stretch、Jessie
运维·docker·容器·debian·alpine·slim·bullseye
中草药z5 小时前
【Docker】零基础上手:原理+Ubuntu/Windows GUI 安装 + 镜像源 / 目录优化
运维·ubuntu·docker·容器·gui·安装·cgroups
勇往直前plus6 小时前
如何利用docker部署springboot应用
spring boot·docker·容器
Tfly__8 小时前
Ubuntu 20.04 安装Aerial Gym Simulator - 基于 Gym 的无人机强化学习仿真器
linux·人工智能·ubuntu·github·无人机·强化学习·运动规划
有谁看见我的剑了?9 小时前
k8s storageclasses nfs-provisioner 部署
docker·容器·kubernetes
忧郁的橙子.9 小时前
安装插件遇到报错时间错误导致签证失败 Errors during downloading metadata for repository ‘baseos‘:
docker
超龄超能程序猿10 小时前
Docker 镜像的导出和还原操作
运维·docker·容器
维尔切10 小时前
Docker 监控平台部署
运维·docker·容器·grafana·prometheus