可以前往我的指引页面,里面有更多docker的笔记:https://blog.csdn.net/qq_41672878/article/details/110430104
目录
docker启动、重启、关闭、查看状态、查看版本
ps:systemctl 是 centos 7.0以上的,以下的用 service,配置文件也是有区分的
配置文件 centos 7.0以下的
[root@VM-0-12-centos /]# vim /etc/sysconfig/docker
配置文件centos 7.0以上的
[root@VM-0-12-centos /]# vim /etc/docker/daemon.json
docker启动
systemctl start docker service docker start
重启docker服务
systemctl restart docker sudo service docker restart
关闭docker
systemctl stop docker service docker stop
查看是否启动成功
systemctl status docker
查看状态
docker ps -a
查看版本
[root@VM-0-12-centos /]# docker version
Client: Version: 1.13.1 API version: 1.26 Package version: docker-1.13.1-203.git0be3e21.el7.centos.x86_64 Go version: go1.10.3 Git commit: 0be3e21/1.13.1 Built: Thu Nov 12 15:11:46 2020 OS/Arch: linux/amd64 Server: Version: 1.13.1 API version: 1.26 (minimum version 1.12) Package version: docker-1.13.1-203.git0be3e21.el7.centos.x86_64 Go version: go1.10.3 Git commit: 0be3e21/1.13.1 Built: Thu Nov 12 15:11:46 2020 OS/Arch: linux/amd64 Experimental: false
设置镜像加速器
去阿里云创建一个账号,搜索容器镜像服务
阿里云:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
步骤:
1 编辑配置文件
[root@VM-0-12-centos /]# vim /etc/docker/daemon.json
2 内容
{ "registry-mirrors": ["https://2vycqjxd.mirror.aliyuncs.com"] }
3 重启
[root@VM-0-12-centos /]# systemctl daemon-reload
[root@VM-0-12-centos /]# systemctl restart docker
4 查看是否设置生效
看这个参数Registry Mirrors:
[root@VM-0-12-centos /]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 66aedde759f33c190954815fb765eedc1d782dd9 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-1062.18.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 1.795 GiB
Name: VM-0-12-centos
ID: OQG4:F6OD:RWLT:BLRE:6BN4:T2LB:PDCF:6K3E:MNLD:KQCW:L62M:7VXG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://2vycqjxd.mirror.aliyuncs.com
Live Restore Enabled: false
Registries: docker.io (secure)