公司使用docker,小组成员人人都是默默使用,也没讲解培训,真是搞笑。
记录自己独自研究及使用:
1)自己安装->失败-系统弄崩->安装成功
目录
- 1. Docker安装-初次安装失败
- 2. Docker安装-初次安装成功
1. Docker安装-初次安装失败
需要使用梯子访问docker官网:Install Docker Engine on Ubuntu
此处有个疑惑:Docker Engine 与Docker、DockerDesktop关系?
该页面“Install Docker Engine on Ubuntu”下,“Installation methods”描述道:
You can install Docker Engine in different ways, depending on your needs(可以根据需要以不同的方式安装Docker Engine)
1)Docker Engine comes bundled with Docker Desktop for Linux. This is the easiest and quickest way to get started.
Docker引擎捆绑了 Linux的Docker桌面。这是 最简单快捷的入门方式
2)Set up and install Docker Engine from Docker’s apt repository.
设置和安装Docker引擎 Docker的apt存储库。
3)Install it manually and manage upgrades manually.
手动安装它并手动管理升级。
4)Use a convenience script. Only recommended for testing and development environments.
使用一个 方便脚本。只有 推荐用于测试和开发环境。
按照上述说明,安装Docker Desktop是最简洁的方式,但是下载Docker Desktop.deb后安装失败,提示如下:
sudo apt-get update
sudo apt-get install ./docker-desktop-amd64.deb
The following packages have unmet dependencies:
docker-desktop : Depends: docker-ce-cli but it is not installable
E: Unable to correct problems, you have held broken packages.
官网文档,
我本来以为是ubuntu20的版本不对,但是也没找到适配ubuntu20的版本,此处有些疑惑?
搜索问题Unable to install Docker Desktop on Ubuntu 22.04
Docker Desktop has a dependency on the docker CLI, which requires the download.docker.com package repository to be set up before installing the docker-desktop package; from the error message, I suspect you didn’t set up that repository (see “step 1” in the instructions; https://docs.docker.com/desktop/install/ubuntu/#install-docker-desktop
(Docker Desktop依赖于docker CLI,这需要在安装docker-桌面包之前设置download.docker.com包存储库;从错误消息来看,我怀疑您没有设置该存储库(请参阅说明中的“步骤1”;https://docs.docker.com/desktop/install/ubuntu/#install-docker-desktop)
结合文档:在 Ubuntu 上安装 Docker 桌面
遂在Docker文档Desktop下载页面中Install Docker Desktop on Ubuntu
Install Docker Desktop
Recommended approach to install Docker Desktop on Ubuntu:
1.Set up Docker’s package repository. See step one of Install using the apt repository.
2.Download latest DEB package.
3.Install the package with apt as follows:
sudo apt-get update
sudo apt-get install ./docker-desktop-<arch>.deb
要首先安装Docker’s package repository,不知道与Docker什么关系,有什么用。
Install using the apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
1.Set up Docker’s apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc# Add the repository to Apt sources:
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 这是个什么命令?
sudo apt-get update
2.Install the Docker packages.
Latest:
To install the latest version, run:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Specific version:
To install a specific version of Docker Engine, start by listing the available versions in the repository:
# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'5:27.0.3-1~ubuntu.24.04~noble
5:27.0.2-1~ubuntu.24.04~noble
...
Select the desired version and install:
VERSION_STRING=5:27.0.3-1~ubuntu.24.04~noble
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
3.Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
需要 使用sudo运行Docker命令
问题:
命令sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 卡住?!!
解决办法:在Ubuntu中安装Docker,添加Docker官方GPG key失败,解决方案
(1)先把官方GPG key下载到本地,下载下来是一个gpg文件
(2)下载到本地后,采用如下命令,安装官方GPG key:
sudo apt-key add ./gpg
Linux apt-key机制后续需要研究
使用了本地sudo apt-key add ./gpg gpg命令后Add the repository to Apt sources添加docker库命令觉得应该修改,但我不知道怎么修改
我是用的下载下来的Desktop.deb文件
20240710使用中科大源能用官方命令gpg运行成功
=======================================
更新于20240715
2. Docker安装-初次安装成功
经过上述失败尝试,在网友指点下,安装成功,遂总结归纳记录。
step1:Docker官方网站找到安装步骤
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc# Add the repository to Apt sources:
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
此处建议:别用deb安装,使用上述apt安装,需挂梯子
step2:解决网络问题,具体如下:
运行clash,终端export Https=127.0.0.1:7890
在“sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc”这一步骤:
此处注意:export不会对sudo生效,
先sudo -i 进入root环境再export
apt安装中需要走docker源,安装过程中代理不能断,除非手动换源
“echo
“deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu
KaTeX parse error: Expected 'EOF', got '&' at position 20: …etc/os-release &̲& echo "VERSION_CODENAME”) stable" |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null”
这个命令之后update会在/etc/apt/sources.list.d/docker.list更换里面的源
#deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu focal stable
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu focal stable
curl吃环境变量,apt不吃环境变量,有的软件不吃环境变量,最简单的方法是用proxychains
可使用apt安装一下。
到此update即成功完成!
helloword验证环境失败:
主要原因是dockerhub被墙,需科学上网。
proxychains配置:sudo vi /etc/proxychains.conf
64行,4改5,端口7891或7890
#socks4 127.0.0.1 9050
socks5 127.0.0.1 7890
proxychains docker pull helloword 但是失败
参考连接:奇技淫巧系列 配置代理解决docker pull命令无法拉取镜像的问题
暂时还未研究,待续。
垃圾docker,作为一个软件,新手安装门槛这么高,还把系统弄崩溃了~~