docker 镜像

docker images: 查看镜像mysql

 

docker制做镜像有两种方式:sql

一、使用docker commit命令。docker

二、使用docker build命令和 Dockerfile 文件。ubuntu

但比较推荐build的方式,由于commit的方式会往当前镜像上累加层,会愈来愈多,也不容易查看。api

 

目前只测试过commit的方式bash

1. 拉取Ubuntu镜像测试

docker pull Ubuntu:16.04ui

2.运行一个容器.net

docker run -it --name zqtest -d ubuntu:16.04 bashcode

注意上面加上-it,不然建立了就退出了

(docker run -it --name test -v /data/test/flow-mete-agent:/code -e "DATABASE_URL=mysql://cdscp:wieQueic0a@10.13.1.50:3306/cdscp?charset=utf8&connect_timeout=5" -e "DB_URL_AUTOMATIC_PRODUCT=mysql://cdsap:zee8Aithiesa@10.13.1.50:3306/automatic_product?charset=utf8&connect_timeout=5" -d ubuntu:16.04 bash)

3. 进入容器

docker exec -it zqtest bash

4. 安装包,软件之类的

5. 退出。

6. 外面commit

格式:
docker commit [选项] <容器ID或容器名> [<仓库名>[:<标签>]]

docker commit -m "set env" zqtest direpos.capitalonline.net/snmp-test:20180529

7. push到仓库

docker push direpos.capitalonline.net/snmp-test:20180529

8. 查看images

root@ubuntu3:~/zq/baseos# docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
direpos.capitalonline.net/snmp-test     20180529            15448786252e        2 minutes ago       441.6 MB
ubuntu                                  16.04               45478fc44aca        4 weeks ago         113 MB
相关文章
相关标签/搜索