qq70191 发表于 2018-5-30 07:28:58

docker下images操作

  获取docker的images

# docker pull centos
latest: Pulling from docker.io/centos
f1b10cd84249: Pull complete
c852f6d61e65: Pull complete
7322fbe74aa5: Pull complete
Digest: sha256:90305c9112250c7e3746425477f1c4ef112b03b4abe78c612e092037bfecc3b7
Status: Downloaded newer image for docker.io/centos:latest
# docker images
REPOSITORY          TAG               IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/centos    latest            7322fbe74aa5      8 weeks ago         172.2 MB  搜索images

# docker search sinatra
INDEX       NAME                                             DESCRIPTION                     STARS   OFFICIAL   AUTOMATED
docker.io   docker.io/tdiary/rpaproxy-sinatra                                                1                  
docker.io   docker.io/andyshinn/sinatra-echo                                                   0                  
docker.io   docker.io/antonyfrancis/sinatra-org                                                0                  
docker.io   docker.io/crohr/docker-sinatra                                                   0                  
docker.io   docker.io/davidyoondrums/sinatra-skeleton                                          0                  
docker.io   docker.io/erikap/ruby-sinatra                  Docker for hosting Sinatra apps   0                  
docker.io   docker.io/garland/sinatra-hello                                                    0                  
docker.io   docker.io/gwjjeff/sinatra                                                          0                  
docker.io   docker.io/hacker314159/ruby-sinatra                                                0                  
docker.io   docker.io/kerona/sinatra                                                         0                  
docker.io   docker.io/kklepper/sinatra_debian                                                0                  
docker.io   docker.io/larmar/sinatra-puppet                                                    0                  
docker.io   docker.io/llamashoes/docker-sinatra                                                0                  
docker.io   docker.io/llamashoes/k8s-example-sinatra                                           0                  
docker.io   docker.io/luisbebop/docker-sinatra-hello-world                                     0                  
docker.io   docker.io/marceldegraaf/sinatra                  Sinatra test app                  0                  
docker.io   docker.io/mattwarren/docker-sinatra-demo                                           0                  
docker.io   docker.io/ryotarai/hello-sinatra                                                   0                  
docker.io   docker.io/shangaijun/sinatra                                                       0                  
docker.io   docker.io/shaoheshan/sinatra                                                       0                  
docker.io   docker.io/synctree/sinatra-echo                                                    0                  
docker.io   docker.io/waitingkuo/benchrock-sinatra                                             0                  
docker.io   docker.io/windurst/sinatra                                                         0                  
docker.io   docker.io/yoheimuta/docker-sinatra                                                 0                  
docker.io   docker.io/zoomix/sinatra-galleria                                                0                    下载training/sinatra,并运行容器
# docker pull training/sinatra
Trying to pull repository docker.io/training/sinatra ...
f0f4ab557f95: Download complete
511136ea3c5a: Download complete
3e76c0a80540: Download complete
be88c4c27e80: Download complete
bfab314f3b76: Download complete
e809f156dc98: Download complete
ce80548340bb: Download complete
79e6bf39f993: Download complete
Status: Downloaded newer image for docker.io/training/sinatra:latest
# docker run -t -i training/sinatra /bin/bash
root@01411ac9a0c4:/# hostname
01411ac9a0c4
root@01411ac9a0c4:/# ping baidu.com
PING baidu.com (123.125.114.144) 56(84) bytes of data.
64 bytes from 123.125.114.144: icmp_seq=1 ttl=50 time=180 ms
64 bytes from 123.125.114.144: icmp_seq=2 ttl=50 time=183 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 180.772/182.024/183.276/1.252 ms  创建自己的container
  方法一:使用docker commit来创建新的container
root@01411ac9a0c4:/# gem install json
# docker commit -m "add json gem" -a='lyao' 01411ac9a0c4 ouruser/sinatra:v2
4d5493c04338a17a8026842f8b3b2a5a5ac9fed74616eaafc2bd66dc9205f379
# docker images
REPOSITORY                   TAG               IMAGE ID            CREATED             VIRTUAL SIZE
ouruser/sinatra            v2                  4d5493c04338      5 seconds ago       451.9 MB
docker.io/centos             latest            7322fbe74aa5      8 weeks ago         172.2 MB
docker.io/training/sinatra   latest            f0f4ab557f95      14 months ago       446.8 MB  -m来指定提交的信息,跟我们使用的版本控制工具一样。
  -a可以指定我们更新的用户信息指定我们要从哪个容器 ID 来创建我们的副本,最后指定目标 image
  的名字。
  这个例子里面,我们指定了一个新用户, ouruser ,使用了 sinatra 的 image ,最后指定了 image 的
  标记 v2 。
  方法二:使用dockerfile来创建container

  
页: [1]
查看完整版本: docker下images操作