Ubuntu 20.04.4安装docker记录

首先我确认了以下自己的Ubuntu版本,不同版本的小伙伴可以参考,但不确保会遇到和我一样的问题。参考官方的安装方法,但是遇到了一点小问题。主要是Depends: docker-ce-cli but it is not installable

Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal

Prerequisites

sudo apt install gnome-terminal

删除之前安装过的版本,如果没安装过就会提示没有找到文件,没有找到包。

sudo apt remove docker-desktop
rm -r $HOME/.docker/desktop
sudo rm /usr/local/bin/com.docker.cli
sudo apt purge docker-desktop

Install Docker Desktop

通过官网下载docker  DEB package. 之后使用指令安装。

sudo apt-get update
sudo apt-get install ./docker-desktop--.deb

在此我遇到了问题:Depends: docker-ce-cli but it is not installable。针对这个问题网上也有很多解答,但是我使用之后,我可以解决问题的是以下指令。最终钥匙要安装docker-ce的,大家也可以试试直接apt-get install docker-ce看可不可行,我这边这样操作的话会提示找不到源。

sudo apt install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.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 -y
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

之后再次运行安装指令即可完成安装。

sudo apt-get install ./docker-desktop--.deb

至此docker就已经安装完毕了。

Launch Docker Desktop

我们已经可以在APP里面知道Docker-desktop了,可以直接打开,看到界面了。当然,也有可能看不到界面(打不开)。不过我们可以使用命令行查看是否安装好了。使用hello-world程序即可。

docker run hello-world

如果正常的话,过一会儿就可以看到下面的输出了,也就安装成功了。 

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

 当然,我们也可以使用systemtcl来开启docker服务,或查看docker的运行状态。(如果你的系统没有systemtcl的话....emmm,那我也不知道怎么办了)

systemctl --user start docker-desktop # 开启服务
systemctl --user status docker-desktop # 查看服务状态

运行状态下,可以看到如下的输出。 

docker-desktop.service - Docker Desktop
     Loaded: loaded (/usr/lib/systemd/user/docker-desktop.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-04-30 09:44:19 CST; 1h 21min ago
   Main PID: 13489 (com.docker.back)

至此已经顺利完成了docker的安装和运行,后面我将会尝试pull一下我需要的镜像尝试运行,再遇到什么问题的话会进行更新。 

你可能感兴趣的:(linux,服务器,ubuntu,docker)