当前位置: 首页 > news >正文

docker学习笔记

标题Ubuntu安装docker

参考:ubuntu22.04使用阿里云Docker镜像源安装Docker(https://blog.csdn.net/qq_26328861/article/details/136205861)

  • 安装依赖包
    sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release

  • 添加阿里云Docker镜像源GPG秘钥
    sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

  • 添加阿里云镜像源
    sudo echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

  • 安装Docker
    sudo apt install docker-ce docker-ce-cli containerd.io

  • 启动Docker服务
    sudo systemctl start docker

  • 查看Docker是否启动成功
    sudo systemctl status docker

  • 查看Docker的版本号,能打印则说明安装成功
    sudo docker -v

  • 运行第一个镜像,hello-world
    sudo docker run hello-world
    出现下面的报错,说明无法访问docker hub网站,需要配置国内的镜像,参考下一节。

Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

配置docker使用国内的镜像

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
    "https://docker.1panel.live",
    "https://docker.m.daocloud.io",
    "https://docker.cloudlayer.icu"]
}
EOF

 sudo systemctl daemon-reload
 sudo systemctl restart docker

sudo docker run hello-world
出现下面的打印则表示运行成功

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete 
Digest: sha256:bfbb0cc14f13f9ed1ae86abc2b9f11181dc50d779807ed3a3c5e55a6936dbdd5
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/

参考:解决目前Docker Hub国内无法访问方法汇总(https://www.cnblogs.com/ppqppl/articles/18499797)

docker常用命令

docker ps	 					#查看正在运行的镜像的状态
docker stop <容器ID>			#停止某个镜像,容器ID可以从docker ps命令中获取

相关文章:

  • DeepSeek 开源周:第五天 - Fire-Flyer 文件系统(3FS)
  • MyBatis-Plus 自动填充功能
  • 本地部署Deepseek+Cherry Studio
  • 【windows driver】 开发环境简明安装教程
  • Windows 11 下正确安装 Docker Desktop 到 D 盘的完整教程
  • anythingLLM和deepseek4j和milvus组合建立RAG知识库
  • 本地大模型编程实战(26)用langgraph实现基于SQL数据构建的问答系统(5)
  • 【CPP面经】CPP后台开发面试经历
  • mac Homebrew安装、更新失败
  • C语言整体梳理-基础篇-结构体
  • 实战-使用 Playbook 批量部署多台 LAMP 环境
  • Android实现漂亮的波纹动画
  • 【线性代数的理解】 为什么说线性代数研究的是空间变换?旋转矩阵坐标转换矩阵
  • 社交APP如何打造高粘性兴趣社群
  • 泰勒公式详解与应用
  • 学生管理前端
  • element-ui infiniteScroll 组件源码分享
  • C# 基于.NET Framework框架WPF应用程序-MQTTNet库实现MQTT消息订阅发布
  • 基于vue框架的游戏博客网站设计iw282(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
  • SQL命令详解之增删改数据
  • 网站怎么在百度搜不到/搜索引擎seo优化
  • 福州网站制作建设/易搜搜索引擎
  • 手机域名注册网站/百度seo找哪里
  • 网站建设套餐表/沈阳专业seo关键词优化
  • 镇江seo公司/宣城网站seo
  • 书籍扉页页面设计模板/seo流量的提升的软件