docker(二)
docker加速
docker加速
docker-ce的配置文件是/etc/docker/daemon.json,此文件默认不存在,需要我们手动创建并进行配置,而docker的加速就是通过配置此文件来实现的。
docker的加速有多种方式:
- docker cn
- 中国科技大学加速器
- 阿里云加速器(需要通过阿里云开发者平台注册帐号,免费使用个人私有的加速器)
[root@localhost ~]# systemctl start docker
[root@localhost ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://k9su2aqs.mirror.aliyuncs.com"]
}
[root@localhost ~]# systemctl restart docker
命令 | 功能 |
---|---|
docker search | 在Docker Hub中搜索图像 |
docker pull | 从注册表中提取图像或存储库 |
docker images | 列出图像 |
docker create | 创建新容器 |
docker start | 启动一个或多个停止的容器 |
docker run | 在新容器中运行命令 |
docker attach | 连接到运行容器 |
docker ps | 列出容器 |
docker logs | 获取容器的日志 |
docker restart | 重新启动容器 |
docker stop | 停止一个或多个正在运行的容器 |
docker kill | 杀死一个或多个正在运行的容器 |
docker rm | 删除一个或多个容器 |
docker exec | 在正在运行的容器中运行命令 |
docker info | 显示系统范围的信息 |
docker inspect | 返回Docker对象的低级信息 |
//查找镜像
[root@localhost ~]# docker search httpd
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 4106 [OK]
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 44
centos/httpd 35 [OK]
solsson/httpd-openidc mod_auth_openidc on official httpd image, ve… 2 [OK]
// NAME 镜像名称
// DESCRIPTION 描述信息
// STARS 赞
// OFFICIAL OK代表是官方镜像
//拉镜像
在虚拟机通网的情况下,在docker官网查找你需要的镜像,把它提取到虚拟机里
[root@localhost ~]# docker pull httpd:latest
latest: Pulling from library/httpd
a2abf6c4d29d: Pull complete
dcc4698797c8: Pull complete
41c22baa66ec: Pull complete
67283bbdd4a0: Pull complete
d982c879c57e: Pull complete
Digest: sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest
//查看当前主机镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest dabbfbe0c57b 7 months ago 144MB
//创建容器
创建方式docker create +name +镜像
[root@localhost ~]# docker create --name wed httpd