docker配置
在ubuntu22.04.2版本配置
-
更新系统软件包:
sudo apt update
-
安装所需的依赖包,以允许APT使用HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
-
添加Docker官方的GPG密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-
添加Docker存储库:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
更新软件包索引:
sudo apt update
-
安装Docker引擎:
sudo apt install docker-ce docker-ce-cli containerd.io
-
验证Docker是否成功安装并运行:
sudo docker run hello-world
- 如果遇到docker: Cannot connect to the Docker daemon at unix:/ / /var/run/docker.sock. Is the docker daemon running?.的报错:建立重启虚拟机再试试
-
如果hello-world正常运行;但前面有报错;则需要配置阿里云镜像这里推荐清华园的镜像
切换到root用户:
sudo -i
将源码备份:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
将原源码替换成清华源:
sudo vim /etc/apt/sources.list
登录清华源找到自己对应的ubuntu版本(本人是ubuntu22.04)
将文件中配置文件清空然后将清华源的配置文件复制上去即可