Docker学习笔记(三)
【摘要】 Docker是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。
Docker镜像的使用
docker官方的镜像库比较慢,在进行镜像操作之前,需要将镜像源设置为国内的站点。
新建文件/etc/docker/daemon.json,输入如下内容:
{
"registry-mirrors" : [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://cr.console.aliyun.com/"
]
}
然后重启docker的服务:
systemctl restart docker
列出本地所有镜像
执行命令docker images
可以查看
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 20.04 f643c72bc252 5 weeks ago 72.9MB
hello-world latest bf756fb1ae65 12 months ago 13.3kB
当前我本地只有刚才安装的两个镜像。
从镜像库中查找镜像
执行命令docker search 镜像名称
可以从docker镜像库中查找镜像。
$ docker search python
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
python Python is an interpreted, interactive, objec… 5757 [OK]
django Django is a free web application framework, … 1039 [OK]
pypy PyPy is a fast, compliant alternative implem… 260 [OK]
joyzoursky/python-chromedriver Python with Chromedriver, for running automa… 57 [OK]
nikolaik/python-nodejs Python with Node.js 57 [OK]
arm32v7/python Python is an interpreted, interactive, objec… 53
circleci/python Python is an interpreted, interactive, objec… 42
centos/python-35-centos7 Platform for building and running Python 3.5… 38
centos/python-36-centos7 Platform for building and running Python 3.6… 30
hylang Hy is a Lisp dialect that translates express… 29 [OK]
arm64v8/python Python is an interpreted, interactive, objec… 24
revolutionsystems/python Optimized Python Images 18
centos/python-27-centos7 Platform for building and running Python 2.7… 17
bitnami/python Bitnami Python Docker Image 10 [OK]
publicisworldwide/python-conda Basic Python environments with Conda. 6 [OK]
d3fk/python_in_bottle Simple python:alpine completed by Bottle+Req… 5 [OK]
dockershelf/python Repository for docker images of Python. Test… 5 [OK]
clearlinux/python Python programming interpreted language with… 4
i386/python Python is an interpreted, interactive, objec… 3
ppc64le/python Python is an interpreted, interactive, objec… 2
centos/python-34-centos7 Platform for building and running Python 3.4… 2
amd64/python Python is an interpreted, interactive, objec… 1
ccitest/python CircleCI test images for Python 0 [OK]
s390x/python Python is an interpreted, interactive, objec… 0
saagie/python Repo for python jobs 0
最好选择官方(OFFICIAL)的镜像,这样的镜像最稳定一些。
下载新的镜像
执行命令docker pull 镜像名称:版本号
即可下载新的镜像。
$ docker pull python:3.8
3.8: Pulling from library/python
6c33745f49b4: Pull complete
ef072fc32a84: Pull complete
c0afb8e68e0b: Pull complete
d599c07d28e6: Pull complete
f2ecc74db11a: Pull complete
26856d31ce86: Pull complete
2cd68d824f12: Pull complete
7ea1535f18c3: Pull complete
2bef93d9a76e: Pull complete
Digest: sha256:9079aa8582543494225d2b3a28fce526d9a6b06eb06ce2bac3eeee592fcfc49e
Status: Downloaded newer image for python:3.8
docker.io/library/python:3.8
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)