Docker镜像管理

不许人间见白头 71 0

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

Docker镜像管理-第1张图片-阿豪运维笔记

4、查看本地镜像

[root@lucky ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              5182e96772bf        5 weeks ago         200MB

5、搜索某个镜像

[root@lucky ~]#  docker search nginx    (其中nginx为镜像名称)
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                                                  Official build of Nginx.                        9577                [OK]                jwilder/nginx-proxy                                    Automated Nginx reverse proxy for docker con…   1402                                    [OK]richarvey/nginx-php-fpm                                Container running Nginx + PHP-FPM capable of…   613                                     [OK]jrcs/letsencrypt-nginx-proxy-companion                 LetsEncrypt container to use with nginx as p…   405                                     [OK]kong                                                   Open-source Microservice & API Management la…   224                 [OK]                webdevops/php-nginx                                    Nginx with PHP-FPM                              113                                     [OK]kitematic/hello-world-nginx                            A light-weight nginx container that demonstr…   108                                     
zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server wi…   66                                      [OK]bitnami/nginx                                          Bitnami nginx Docker Image                      58                                      [OK]1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          43                                      [OK]linuxserver/nginx                                      An Nginx container, brought to you by LinuxS…   39                                      
tobi312/rpi-nginx                                      NGINX on Raspberry Pi / armhf                   20                                      [OK]blacklabelops/nginx                                    Dockerized Nginx Reverse Proxy Server.          12                                      [OK]wodby/drupal-nginx                                     Nginx for Drupal container image                10                                      [OK]webdevops/nginx                                        Nginx container                                 8                                       [OK]nginxdemos/hello                                       NGINX webserver that serves a simple page co…   8                                       [OK]centos/nginx-18-centos7                                Platform for running nginx 1.8 or building n…   7                                       
centos/nginx-112-centos7                               Platform for running nginx 1.12 or building …   5                                       
1science/nginx                                         Nginx Docker images that include Consul Temp…   4                                       [OK]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]toccoag/openshift-nginx                                Nginx reverse proxy for Nice running on same…   1                                       [OK]travix/nginx                                           NGinx reverse proxy                             1                                       [OK]mailu/nginx                                            Mailu nginx frontend                            1                                       [OK]ansibleplaybookbundle/nginx-apb                        An APB to deploy NGINX                          0                                       [OK]

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时,则会彻底删除整个镜像,所有标签也会一同删除

标签: Docker

抱歉,评论功能暂时关闭!