docker pull centos//可以下载centos镜像,速度很慢
1、配置加速器
# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://nlum9u1b.mirror.aliyuncs.com"]
}说明:这个url为加速器地址,需要同学们自行到阿里云申请
https://yq.aliyun.com/articles/29941 申请地址
配置完加速器,
2、重启docker服务,
[root@lucky ~]# systemctl restart docker
3、测试下载
[root@lucky ~]# docker pull centos

4、查看本地镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 49f7960eb7e4 2 weeks ago 200MB
5、搜索某个镜像
[root@ahao01 ~]# docker search nginx //搜索镜像,其中nginx是关键词 NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 8785 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1349 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 578 [OK] jrcs/letsencrypt-nginx-proxy-companion LetsEncrypt container to use with nginx as p… 377 [OK] kong Open-source Microservice & API Management la… 194 [OK] webdevops/php-nginx Nginx with PHP-FPM 106 [OK] kitematic/hello-world-nginx A light-weight nginx container that demonstr… 99 bitnami/nginx Bitnami nginx Docker Image 54 [OK] zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 54 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 36 [OK] linuxserver/nginx An Nginx container, brought to you by LinuxS… 36 tobi312/rpi-nginx NGINX on Raspberry Pi / armhf 19 [OK] nginxdemos/nginx-ingress NGINX Ingress Controller for Kubernetes . Th… 11 wodby/drupal-nginx Nginx for Drupal container image 9 [OK] blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 9 [OK] webdevops/nginx Nginx container 8 [OK] centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 6 1science/nginx Nginx Docker images that include Consul Temp… 4 [OK] centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 3 pebbletech/nginx-proxy nginx-proxy sets up a container running ngin… 2 [OK] behance/docker-nginx Provides base OS, patches and stable nginx f… 2 [OK] travix/nginx NGinx reverse proxy 1 [OK] toccoag/openshift-nginx Nginx reverse proxy for Nice running on same… 1 [OK] mailu/nginx Mailu nginx frontend 0 [OK] ansibleplaybookbundle/nginx-apb An APB to deploy NGINX
6、给你做的镜像做个标签标记
[root@lucky ~]# docker tag centos ahaotestcentos [root@lucky ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ahaotestcentos latest 5182e96772bf 5 weeks ago 200MB centos latest 5182e96772bf 5 weeks ago 200MB 其中REPOSITORY为标签名称
7、更改tag标签用法
[root@lucky ~]# docker tag centos ahaotestcentos:20180912 (其中20180912为tag标签的内容)
8、把镜像启动为容器
[root@lucky ~]# docker run -itd centos4df94c8a4bdcd8c91204762ade08e48784f5b5eaaf436201168362df6b54bfb5 -i表示让容器的标准输入打开,-t表示分配一个伪终端,-d表示后台启动,要把-i -t -d 放到镜像名字前面
9、查看运行的容器,加上-a选项后可以查看所有容器,包括未运行的
[root@lucky ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4df94c8a4bdc centos "/bin/bash" 10 minutes ago Up 10 minutes hardcore_murdock
10、删除某个镜像
[root@lucky ~]# docker rmi ahaocentos Untagged: ahaocentos:latest
用来删除指定镜像, 其中后面的参数可以是tag,如果是tag时,实际上是删除该tag。当后面的参数为镜像ID时,则会彻底删除整个镜像,所有标签也会一同删除

