docker介绍以及基本配置

介绍

  • Docker Image(镜像)就是一个集装箱,可以看作是封装成了一个小型的操作系统。
  • Docker就是一个容器,Image可以在上面运行。
  • 这样的机制使得,我们只要有Docker,就能够在不同系统运行Image
  • Docker和虚拟机有很大的相似之处,不过Docker更轻量级,每次不会运行出整个大的操作系统。
  • 如图所示,VMware需要建立多个Guest OS,而docker直接利用Host OS

Linux

参考官方文档

我这里用的是Ubuntu,其余操作系统参考其他文档。

  • 移除旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
  • 准备相关依赖
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg
  • 使用阿里源
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
  • 写入软件源
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
  • 安装社区版docker
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
  • 测试运行
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/

Windows

我的系统是家庭版(懒),这里还是参考官方文档

  • 下载Docker Desktop,直接安装。

  • 至少选中安装WSL2进行,装完后会要求重启。

  • 重启后可能报错,点击链接安装更新内核。

  • Restart之后,我出现了如下情况。

  • 按照网上的方法,以管理员身份打开CMD,输入命令。

netsh winsock reset
  • 重启之后,安装成功。

命令

参考官方文档

  • 相关信息
#显示版本 docker version #显示详细信息 docker info #显示COMMAND帮助 docker {COMMAND} --help
  • 其他命令

__EOF__

本文作者ch3uhx9
本文链接https://www.cnblogs.com/cheuhxg/p/14494126.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   CH3UHX9  阅读(150)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示