images介绍
docker把下载好的镜像上传到docker本地镜像仓库中,如果本地镜像仓库中不存在需要用到的镜像,docker会从一个镜像库中去下载所需镜像,默认的公共仓库是Docker HUB。
1.显示本机上的images
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos-min latest fba4b9bd24bf 7 minutes ago 435MB
centos7-min latest 36ca2b752ffe 7 minutes ago 0B
centos7 latest f9c9fbed3702 8 minutes ago 589MB
mariadb 3.0.7 8ee7534c52b2 56 minutes ago 355MB
2.获取一个镜像
docker pull nginx
3.查找一个镜像(docker hub上)
docker search mysql
4.查看镜像信息
docker images centos
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 470671670cac 4 months ago 237MB
5.获取镜像元数据
docker inspect centos:latest ##部分截图
[
{
"Id": "sha256:470671670cac686c7cf0081e0b37da2e9f4f768ddc5f6a26102ccd1c6954c1ee",
"RepoTags": [
"centos:latest"
],
"RepoDigests": [
"centos@sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700"
],
"Parent": "",
"Comment": "",
"Created": "2020-01-18T00:26:46.850750902Z",
"Container": "57333b28d93d47fedc0cc5c995092b9266fa4b73b64f3f88d42a08e46f1aab48",
创建自己的images
##从一个images扩展
docker pull centos
docker run -i -t centos:latest /bin/bash
##进入到容器的bash
[root@c8bdc94e7965 /]#yum -y install mariadb
exit
docker commit -m "add mariadb" -a "test" c8bdc94e7965
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb 3.0.7 8ee7534c52b2 About an hour ago 355MB
上传镜像
##用的docker hub
网站:https://hub.docker.com/
docker login ##连接或创建一个docker hub账户
docker tag mariadb:3.0.7 mrlxxx/mariadb:3.0.7 ##给镜像设置一个标签
docker push mrlxxx/mariadb:3.0.7
导出与导入镜像
1.从本地文件系统导入
##openvz
镜像下载网址:https://wiki.openvz.org/Download/template/precreated
cat centos-7-x86_64-minimal.tar.gz | docker import - centos7-min
##参数说明 - 后面为设置标签名
2.导出镜像到本地文件
docker save -o mariadb_test.tar mariadb:3.0.7
##参数说明 -o 设置tar包名称
3.载入镜像
##只能载入save导出的镜像
docker load --input mariadb_test.tar