Docker笔记3 | 在Ubuntu下安装Docker

简介: Docker笔记3 | 在Ubuntu下安装Docker

1 支持环境

Docker 支持以下版本的 Ubuntu 操作系统:

Focal 20.04 (LTS)
Bionic 18.04 (LTS)
Xenial 16.04 (LTS)

2 卸载旧的docker

sudo apt-get remove docker \
docker-engine \
docker.io
  • 旧版本的 Docker 称为 docker 或者 docker-engine
  • 因为我的Ubuntu是新装的,目前未安装docker,可以从卸载命令可以看出来:

在这里插入图片描述

3 安装Docker

3.1 添加HTTPS 传输的软件包以及 CA 证书

  • 因为使用 APT 安装,apt 源使用 HTTPS 以确保软件下载过程中不被篡改:
sudo apt-get update

在这里插入图片描述

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

在这里插入图片描述

3.2 添加软件源的 GPG 密钥

  • 目的是确认所下载软件包的合法性;
# 以后文章建议使用国内源
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

#  官方源
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
-

在这里插入图片描述

3.3 添加 Docker 软件源

  • sources.list 中添加 Docker 软件源:
$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
# 官方源
# $ sudo add-apt-repository \
# "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) \
# stable"

在这里插入图片描述

3.4 安装Docker

  • 使用如下命令:
sudo apt-get update

在这里插入图片描述

sudo apt-get install docker-ce docker-ce-cli containerd.io

在这里插入图片描述

3.5 自动安装


$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

在这里插入图片描述

4 Docker启动和验证是否安装ok

4.1 启动Docker

$ sudo systemctl enable docker
$ sudo systemctl start docker

在这里插入图片描述

4.2 docker 用户组建立

  • 将需要使用 docker 的用户加入 docker 用户组;
  • 建议用户组:
$ sudo groupadd docker

在这里插入图片描述

  • 将当前用户加入刚才建议的docker组:
$ sudo usermod -aG docker $USER
  • 使用:cat /etc/group可以查看加入的用户组;

在这里插入图片描述

4.3 验证docker

  • 退出重新登录,输入命令查看:
$ docker run hello-world
  • 输出以下信息表明安装成功了~
noamanelson@noamanelson-Virtual-Machine:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e
Status: Downloaded newer image for hello-world:latest

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/
目录
相关文章
|
10天前
|
缓存 Ubuntu Linux
Docker Buildx 简介与安装指南
Docker Buildx 是一个强大的工具,提供了多架构构建、并行构建和高级缓存管理等功能。通过正确安装和配置 Buildx,可以显著提升 Docker 镜像的构建效率和灵活性。希望本文能帮助你更好地理解和使用 Docker Buildx,以提高开发和部署的效率。
124 16
|
7天前
|
存储 虚拟化 Docker
Docker Desktop 4.38 安装与配置全流程指南(Windows平台)
Docker Desktop 是容器化应用开发与部署的一体化工具,支持本地创建、管理和运行 Docker 容器。4.38 版本新增 GPU 加速、WSL 2 性能优化和 Kubernetes 1.28 集群管理功能,适用于微服务开发和 CI/CD 流水线搭建。安装要求为 Windows 10 2004 及以上(64 位),需启用 Hyper-V 或 WSL 2。硬件最低配置为 4GB 内存、20GB 存储和虚拟化技术支持的 CPU。安装步骤包括启用系统功能、下载并运行安装程序,完成后配置镜像加速并验证功能。常见问题涵盖 WSL 2 安装不完整、磁盘空间清理及容器外网访问等。
755 12
|
19天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
107 25
|
1天前
|
NoSQL Ubuntu 网络安全
在 Ubuntu 20.04 上安装和配置 Redis
在 Ubuntu 20.04 上安装和配置 Redis 的步骤如下:首先更新系统包,然后通过 `apt` 安装 Redis。安装后,启用并启动 Redis 服务,检查其运行状态。可选配置包括修改绑定 IP、端口等,并确保防火墙设置允许外部访问。最后,使用 `redis-cli` 测试 Redis 功能,如设置和获取键值对。
13 1
|
8天前
|
弹性计算 运维 Ubuntu
在阿里云ECS云服务器上安装、配置及高效使用Docker与Docker Compose
本文介绍了在阿里云ECS上使用Ubuntu系统安装和配置Docker及Docker Compose的详细步骤。通过这些工具,可以快速部署、弹性扩展和高效管理容器化应用,满足开发和运维需求。内容涵盖Docker的安装、镜像源配置、创建Web程序镜像以及使用Docker Compose部署WordPress等实际操作,并分享了使用体验,展示了阿里云实例的高性能和稳定性。
152 4
|
7天前
|
Ubuntu TensorFlow 算法框架/工具
如何在Ubuntu上安装TensorFlow 24.04
如何在Ubuntu上安装TensorFlow 24.04
32 1
|
1月前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
80 20
|
1月前
|
Ubuntu API 网络虚拟化
ubuntu22 编译安装docker,和docker容器方式安装 deepseek
本脚本适用于Ubuntu 22.04,主要功能包括编译安装Docker和安装DeepSeek模型。首先通过Apt源配置安装Docker,确保网络稳定(建议使用VPN)。接着下载并配置Docker二进制文件,创建Docker用户组并设置守护进程。随后拉取Debian 12镜像,安装系统必备工具,配置Ollama模型管理器,并最终部署和运行DeepSeek模型,提供API接口进行交互测试。
345 15
|
1天前
|
Ubuntu Linux Docker
如何在Ubuntu 20.04系统中安装Docker
安装 Docker 引擎的步骤如下:首先更新系统包索引 (`sudo apt update`),安装必要依赖包 (`apt-transport-https` 等),添加 Docker 官方 GPG 密钥及 APT 仓库。接着再次更新包索引并安装 Docker 引擎及相关工具 (`docker-ce` 等)。最后启动 Docker 服务并设置开机自启,通过 `docker --version` 和运行测试容器 (`sudo docker run hello-world`) 验证安装是否成功。
20 0
|
1月前
|
消息中间件 Kafka Docker
docker compose 安装 kafka
通过本文的步骤,您可以快速在本地使用 Docker Compose 安装并配置 Kafka 和 Zookeeper。Docker Compose 简化了多容器应用的管理,方便快速搭建和测试分布式系统。
90 2