什么是docker
docker中的容器:
- lxc --> libcontainer --> runC
OCI&OCF
OCI
Open Container-initiative
- 由Linux基金会主导于2015年6月创立
- 旨在围绕容器格式和运行时制定一个开放的工业化标准
- contains two specifications
- the Runtime Specification(runtime-spec)
- the Image Specification(image-spec)
OCF
Open Container Format
runC is a CLI tool for spawning and running containers according to the OCI specification
- Containers are started as a child process of runC and can be embedded into various other systems without having to run a daemon
- runC is built on libcontainer, the same container technology powering millions of Docker Engine installations
docker提供了一个专门容纳容器镜像的站点:https://hub.docker.com
docker架构
docker镜像与镜像仓库
为什么镜像仓库名字是Registry而不是repository?在docker中仓库的名字是以应用的名称取名的。
镜像是静态的,而容器是动态的,容器有其生命周期,镜像与容器的关系类似于程序与进程的关系。镜像类似于文件系统中的程序文件,而容器则类似于将一个程序运行起来的状态,也即进程。所以容器是可以删除的,容器被删除后其镜像是不会被删除的。
docker对象
Docker镜像,容器,网络,卷,插件等是Docker对象。
在Dockerland,有镜像,有容器。这两者密切相关,但截然不同。但这一切都始于Dockerfile。
一个Dockerfile是您创建镜像时,你建立的一个文件。它包含一堆指令,告知Docker如何构建Docker镜像。
你可以把它与烹饪联系起来。在烹饪中你有食谱。通过配方,您可以了解必须采取的所有步骤,以便生成您想要烹饪的任何内容。烹饪行为正在建立食谱。
docker安装
下载 centos源 epel源 docker源
docker加速
启动服务 开机自启
[root@localhost ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendo>
Active: active (running) since Sun 2022-04-24 16:11:11 CST; 36s
[root@localhost ~]# cd /etc/docker/
[root@localhost docker]# ls
key.json
[root@localhost docker]# vi daemon.json
[root@localhost docker]# vi daemon.json
[root@localhost docker]# systemctl daemon-r