Bootstrap

Docker镜像管理与容器管理

一、镜像管理

1.1、配置镜像加速器

默认情况从 Docker Hub 上下载镜像资源,但速度比较慢,这里使用阿里云的容器镜像服务
在这里插入图片描述

1.2、查看配置结果

命令:docker info

...
 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://xxxxxxxx.mirror.aliyuncs.com/
 Live Restore Enabled: false

1.3、镜像操作

Docker 镜像是由文件系统叠加而成(是一种文件的存储形式),最底端是一个文件引 导系统(bootfs)

1.3.1、搜索镜像

mysql为搜索关键字

[root@localhost docker]# docker search mysql
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   9790                [OK]                
mariadb                           MariaDB is a community-developed fork of MyS…   3572                [OK]                
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   717                                     [OK]
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   79                                      
mysql/mysql-cluster               Experimental MySQL Cluster Docker images. Cr…   73                                      
...
1.3.2、下载镜像
[root@localhost docker]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
...
1.3.3、查看镜像
[root@localhost docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               latest              e3fcc9e1cc04        10 days ago         544MB
1.3.4、删除镜像

docker rmi REPOSITORY:TAG(或docker rmi IMAGE_ID)

二、容器管理

2.1、新建容器

创建两个容器

[root@localhost docker]# docker create -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=root mysql
8e672109a7931b12236d86176c82bbe9d
;