Docker学习记录-01
docker文档地址
Docker overview | Docker Documentation
帮助命令
docker 命令 --help
镜像命令
#显示镜像
[root@VM-12-9-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 7425d3a7c478 4 days ago 142MB
whyour/qinglong latest 2b6f05a5ef3d 6 months ago 419MB
centos latest 5d0da3dc9764 8 months ago 231MB
#可选项
Options:
-a, --all 显示所有镜像
--digests 更深层次的挖掘
-q, --quiet 只显示镜像ID
#搜索镜像
[root@VM-12-9-centos ~]# docker search tomcat
#搜索添加过滤
[root@VM-12-9-centos ~]# docker search tomcat --filter=stars=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 3319 [OK]
#下载镜像 比如下载mysql镜像
[root@VM-12-9-centos ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
c32ce6654453: Pull complete #采用分层下载方式
415d08ee031a: Pull complete
7a38fec2542f: Pull complete
352881ee8fe9: Pull complete
b8e20da291b6: Pull complete
66c2a8cc1999: Pull complete
d3a3a8e49878: Pull complete
e33a48832bec: Pull complete
410b942b8b28: Pull complete
d5323c9dd265: Pull complete
3212737f31c0: Pull complete
d0032d4b0dc5: Pull complete
Digest: sha256:a0805d37d4d298bd61e0dfa61f0ddf6f4680b453fa25d7aad420485a62417eab
Status: Downloaded newer image for mysql:latest #默认下载
#指定版本下载
[root@VM-12-9-centos ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
c32ce6654453: Already exists #分层下载这些模块刚才已经下载不需要在下载
415d08ee031a: Already exists
7a38fec2542f: Already exists
352881ee8fe9: Already exists
b8e20da291b6: Already exists
66c2a8cc1999: Already exists
d3a3a8e49878: Already exists
172aabfba65c: Pull complete
fea17d0b1d1e: Pull complete
fff7f5411ca9: Pull complete
c33d43428e07: Pull complete
Digest: sha256:16e159331007eccc069822f7b731272043ed572a79a196a05ffa2ea127caaf67
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
#删除镜像 指定id删除
[root@VM-12-9-centos ~]# docker rmi -f 76152be68449
#删除镜像 全部删除
[root@VM-12-9-centos ~]# docker rmi -f $(docker images -aq)
容器命令
说明:有了镜像才可以创建容器
运行容器&列出容器
docker run [可选参数] images
#参数说明
--name="名字" 容器名字用来区分容器
-d 后台方式运行
-it 交互方式运行,进入容器
-p 指定容器端口 -p 8080:8080
-p 8080:8080(主机端口:容器端口)最常用
-p 容器端口
容器端口
—P 随机端口
#测试 启动centos镜像并进入容器