1)设置docker镜像加速
docker安装后默认没有daemon.json这个配置文件,需要进行手动创建。配置文件的默认路径:/etc/docker/daemon.json。
daemon.json文件可配置的参数表,我们在配置的过程中,只需要设置我们需要的参数即可,不必全部写出来。详细参考官网。
官方的配置地址:https://docs.docker.com/engine/reference/commandline/dockerd/#/configuration-reloading
官方的配置地址:https://docs.docker.com/engine/reference/commandline/dockerd/#options
官方的配置地址:https://docs.docker.com/engine/reference/commandline/dockerd/#/linux-configuration-file
示例:
[root@wsl ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://registry.docker-cn.com"] } [root@wsl ~]#
添加完成后保存,下一步执行加速生效
1、修改完重载文件
[root@wsl ~]# systemctl daemon-reload /重载 [root@wsl ~]# systemctl restart docker /重启docker服务 [root@wsl ~]# systemctl status docker /查看状态
查看服务,是否采用docker镜像加速
[root@wsl ~]# docker info Client: Debug Mode: false Registry Mirrors: https://registry.docker-cn.com/ Live Restore Enabled: false
2)docker查看版本和docker info信息检查
[root@wsl ~]# docker version Client: Docker Engine - Community Version: 19.03.5 API version: 1.40 Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:25:41 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.5 API version: 1.40 (minimum version 1.12) Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:24:18 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.10 GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339 runc: Version: 1.0.0-rc8+dev GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 docker-init: Version: 0.18.0 GitCommit: fec3683 [root@wsl ~]#
docker info:
[root@wsl ~]# docker info Client: Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 2 Server Version: 19.03.5 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs 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: runc Default Runtime: runc Init Binary: docker-init containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-514.26.2.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 1.796GiB Name: wsl ID: WDDJ:DBSB:2RMA:PMXU:PDO6:ZWSX:B5WU:4CMK:TTGY:D3A5:QEBK:O3D5 Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://registry.docker-cn.com/ Live Restore Enabled: false
3)对镜像的操作:
1.获取镜像
增:
docker pull 镜像名:TAG
删:
删除镜像,我们不能直接删除有容器依赖的镜像
docker rmi 镜像名/ID
docker rmi -f 镜像名/ID
改:
docker tag
查:
查看本地镜像
docker images
4)对容器的操作:
增:
1.创建并运行容器
docker run --name 容器名字 -d -p 宿主机端口:容器端口 基础镜像
例子: docker run --name web1 -d -p 80:80 nginx:latest
删:
删除容器,我们不能直接删除一个正在运行的容器,需要先停止再删除,或者-f,强制删除
docker rm web1
docker rm -f web1
改:
容器重命名
docker rename
容器启动和停止
docker start/stop/restart 容器名
docker pause 容器名 \暂停容器 (挂起)
docker unpause 容器名 \取消暂停容器
docker update \更新容器的配置
docker cp \容器和宿主机之间复制文件,默认覆盖已有的文件
查:
查看正在运行的容器
docker ps
查看所有的容器
docker ps -a
docker stats 容器名 \查看容器运行状态
docker top 容器名 \查看容器正在运行的进程