欢迎访问我的网站,希望内容对您有用,感兴趣的可以加入我们的社群。

ubuntu 22.04安装Docker

Linux 迷途小书童 7个月前 (03-14) 1549次浏览 1个评论

视频看这里

Youtube

简介

本文介绍如何在 ubuntu 系统上安装 Docker,安装方法适用于 ubuntu 20.04 及以上版本,安装之前,确保防火墙关闭(如 ufw 或者 firewalld)。

安装步骤

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

# 加入apt源
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

接着就可以来安装 Docker

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

最后,再来验证一下安装情况

sudo 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/

至此,就说明 Docker 已经安装成功了。

喜欢 (0)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽