Ubuntu安装docker

这篇博客详细介绍了在Ubuntu系统中安装Docker的过程,包括更新包索引、安装必要组件、添加Docker官方GPG密钥、设置Docker仓库以及安装和验证Docker Engine。通过遵循这些步骤,用户可以成功安装并确认Docker运行正常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参照官网提供安装方法,安装即可,遇到如下提问:

Do you want to continue? [Y/n] Y

一律录入:Y(大小写皆可)

docker官网ubuntu安装docker方法:Install Docker Engine on Ubuntu | Docker Documentation

官网提示安装有三种方法,我使用的是Install using the repository。

安装过程:

  1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:

    sudo apt-get update
    
    sudo apt-get install \
        ca-certificates \
        curl \
        gnupg \
        lsb-release
    
  2. Add Docker’s official GPG key:

    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

 3.Use the following command to set up the repository:

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

Install Docker Engine

  1. Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose

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

 2.Verify that Docker Engine is installed correctly by running the hello-world image.

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/
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值