安装docker环境
-
安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
-
添加 yum 软件源
yum-config-manager --add-repo \ https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
-
安装
yum install docker-ce docker-ce-cli containerd.io
-
启动docker
systemctl enable docker systemctl daemon-reload systemctl start docker
-
查看docker版本
docker version
-
镜像加速配置
#vi /etc/docker/daemon.json mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://registry.docker-cn.com","https://nrbewqda.mirror.aliyuncs.com","https://dmmxhzvq.mirror.aliyuncs.com"], "insecure-registries": ["127.0.0.1:5000","192.168.123.120:5000","192.168.123.122:5000"] } EOF systemctl daemon-reload systemctl restart docker
-
查看正在运行的容器
docker ps docker container ls
-
查看所有容器
docker ps -a
-
将本地镜像推送至官方仓库
docker login -u elang0705 -p ******* # 登录官方docker hub docker tag thanhptr/kafka-eagle:latest elang0705/kafka-eagle:1.0 # 标记成自己的镜像 docker push elang0705/kafka-eagle:1.0 # 推送至官方
搭建私有仓库
创建私有仓库
1. 从官方拉取镜像
docker pull registry:2
2. 创建私库
docker run -d --restart=always -v /opt/registry:/data/docker/lib/registry -p 5000:5000 --name shaangu_docker_registry registry:2
修改配置文件
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://s0qcmr79.mirror.aliyuncs.com","https://registry.docker-cn.com"],
"insecure-registries":["192.168.123.122:5000"]
}
systemctl daemon-reload
systemctl restart docker
curl http://192.168.123.120:5000/v2/_catalog
重命名镜像
docker tag thanhptr/kafka-eagle:latest 192.168.123.10:5001/kafka-eagle:1.0
上传标记镜像
docker push 192.168.123.122:5001/kafka-eagle
查看仓库中的镜像
curl 192.168.123.122:5000/v2/_catalog # 看到{"repositories":["kafka-eagle"]},表明镜像已经被上传成功了。
删除已有镜像
docker image rm 192.168.123.10:5001/kafka-eagle:1.0
删除私有仓库镜像
1. 通过命令行获取镜像对应sha256值
curl --header "Accept:application/vnd.docker.distribution.manifest.v2+json" -I -XGET http://127.0.0.1:5000/v2/kafka-eagle/manifests/1.0 # 得到 Docker-Content-Digest: sha256:78d048d4b78c1ecaaf8cebdc7262a6f2d7206507e66682a4172cffaed235b9b2
2. curl -I -XDELETE http://127.0.0.1:5000/v2/kafka-eagle/manifests/sha256:78d048d4b78c1ecaaf8cebdc7262a6f2d7206507e66682a4172cffaed235b9b2
修改docker默认的数据挂载路径
https://www.cnblogs.com/atuotuo/p/7217331.html
[root@node3 docker]# touch daemon.json
[root@node3 docker]# ll
总用量 4
-rw-r--r--. 1 root root 0 7月 26 16:52 daemon.json
-rw-------. 1 root root 244 7月 26 16:45 key.json
[root@node3 docker]# vi daemon.json
[root@node3 docker]# systemctl daemon-reload
[root@node3 docker]# systemctl restart docker.service
[root@node3 docker]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1127.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 56
Total Memory: 125.2GiB
Name: node3
ID: 7I3W:UB5O:KC4N:WGKK:4GDC:VOG5:HXUM:5A7H:7M2I:CQTD:UHRD:PCSC
Docker Root Dir: /data/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
docker-compose安装
https://docs.docker.com/compose/install/