什么是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对象
When you use docker, you are creating and using images, containers, networks, volumes, pluginns, and other objects.
- IMAGES
- An image is a read-only template with instructions for creating a docker container.
- Often, an image is based on another image, with some additional customization.
- You might create your own images or you might only use those created by others and published in a registry.
- CONTAINERS
- A conntainer is a runnable instance of an image.
- You can create, run, stop, move, or delete a container using the docker API or CLI.
- You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.
安装及使用docker
//配置yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
redhat.repo
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls
[root@localhost yum.repos.d]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.5 (Ootpa)
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2495 100 2495 0 0 5144 0 --:--:-- --:--:-- --:--:-- 5133
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhos