Docker CE在17.03版本之前叫Docker Engine,版本号从0.1.0(2013-03-23)~1.13.1(2017-02-08),详见https://docs.docker.com/release-notes/docker-engine/
Docker分为CE和EE。CE即社区版(免费);EE即企业版,强调安全,付费使用。
Docker在1.13.1版本之后,从2017年3月1日开始,Docker的发布发生了变化,包括命名变动、发布周期的改善、版本号方案的变更。
在2017年3月2日,docker团队宣布企业版Docker Enterprise Edition(EE)发布。为了一致,免费的Docker Engine改名为 Docker Community Edition(CE),并且采用基于时间的版本号方案。就在这一天,Dcoker EE和Docker CE的17.03版本发布,这也是第一个采用新的版本号方案的版本。
Docker CE/EE每个季度发布一次季度版本,称为Stable版本。也就是说每年会发布4个季度版本。17.03,17.06,17.09,17.12就是2017年的4个季度的版本号。同时Docker CE每个月还会发布一个Edge版本,比如17.04,17.05,17.07,17.08,17.10,17.11。
在基于时间的发布方案中,版本号格式为:YY.MM.
mkdir docker
wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-19.03.15.tgz
tar xvf docker-19.03.15.tgz
cp docker/* /usr/bin/
准备配置文件containerd.service
可以从已经安装好docker服务器上复制,路径/lib/systemd/system/
启动containerd并查看状态
systemctl enabled containerd && systemctl start containerd && systemctl status containerd
准备配置文件docker.socket
可以从已经安装好docker服务器上复制,路径/lib/systemd/system/
groupadd docker
systemctl enabled docker.socket
systemctl start docker.socket
准备配置文件docker.service
可以从已经安装好docker服务器上复制,路径/lib/systemd/system/
启动docker.service
systemctl enabled docker
systemctl start docker
wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-19.03.15.tgz
tar xf docker-19.03.15.tgz
cp docker/* /usr/bin/
dockerd &
docker info
docker run hello-world
参考清华大学开源软件镜像站 https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
重启docker服务生效
# 通过镜像名搜索
docker search nginx
# 指定镜像版本号
docker search nginx:1.20.1
docker search alpine
docker pull nginx
docker pull alpine
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest 14119a10abf4 5 days ago 5.6MB
nginx latest dd34e67e3371 2 weeks ago 133MB
hello-world latest d1165f221234 6 months ago 13.3kB
docker save alpine > alpine.tgz
# 可以将导出的文件复制到其他已经安装了docker服务的服务器上将文件导入
docker load < alpine.tgz
e2eb06d8af82: Loading layer [==================================================>] 5.865MB/5.865MB
Loaded image: alpine:latest
# 删除镜像hello-world
# 报错提示有正在使用此镜像的容器,需先删除容器
root@client1:~/docker/docker# docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container f29a88c37cf3 is using its referenced image d1165f221234
# 查看所有容器
root@client1:~/docker/docker# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f29a88c37cf3 hello-world "/hello" About an hour ago Exited (0) About an hour ago dazzling_dijkstra
5d668569bfcc hello-world "/hello" About an hour ago Exited (0) About an hour ago awesome_kepler
f1bfe0a2aa34 hello-world "/hello" About an hour ago Exited (0) About an hour ago suspicious_greider
# 通过容器ID删除容器
root@client1:~/docker/docker# docker rm f29a88c37cf3 5d668569bfcc f1bfe0a2aa34
f29a88c37cf3
5d668569bfcc
f1bfe0a2aa34
# 再次删除镜像成功
root@client1:~/docker/docker# docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726
Deleted: sha256:f22b99068db93900abe17f7f5e09ec775c2826ecfe9db961fea68293744144bd
# 查看 hello-world镜像已经被删除
root@client1:~/docker/docker#
root@client1:~/docker/docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest 14119a10abf4 5 days ago 5.6MB
nginx latest dd34e67e3371 2 weeks ago 133MB
原文:https://www.cnblogs.com/yanql/p/15220012.html