docker入门(一)
一、什么是docker
docker是一个开源项目,诞生于2013年初,最初是dotCloud公司内部的一个业余项目。它基于Google公司推出的Go语言实现,后来进入Linux基金会,遵从了Apache2.0协议,项目代码在GitHub上进行维护
docker是一个开源项目,诞生于2013年初,最初是dotCloud公司内部的一个业余项目。它基于Google公司推出的Go语言实现,后来进入Linux基金会,遵从了Apache2.0协议,项目代码在GitHub上进行维护
docker主要目标:
通过对应用组件的封装、分发、部署、运行等生命周期的管理,达到应用级别的一次封装,到处运行的目的(这里的应用组件可以是一个web应用,也可以是一套数据库服务,也可以是一个操作系统的编译器)
二、为什么要使用docker
环境隔离
更快速的交付部署
更高效的资源利用
易迁移扩展
简单的更新管理
三、安装docker(必须64bit的操作系统(因为docker是go语言实现的,go语言需要64bit的环境)
1、sudo yum update #更新
2、yum install net-toools #看网络信息
3、配置yum源
sudo vim /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
4、sudo yum install docker
5、service docker start #启动docker
6、docker version #查看docker版本
7、测试docker是否安装成功
[zzq@localhost ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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.
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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
这样的结果就算成功了。
8、docker一些实用命令:
docker查看正在运行的容器:
[root@VM_0_6_centos software]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45459695f7db ff426288ea90 "/bin/bash" 5 weeks ago Up 5 weeks elated_keller
docker查看容器IP命令:
docker inspect 容器ID | grep IPAddress
[root@VM_0_6_centos software]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45459695f7db ff426288ea90 "/bin/bash" 5 weeks ago Up 5 weeks elated_keller
[root@VM_0_6_centos software]# docker inspect 45459695f7db | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现