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
相關文章
相關標籤/搜索