博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Build Your Own Images
阅读量:4031 次
发布时间:2019-05-24

本文共 3311 字,大约阅读时间需要 11 分钟。

Build your own images

Docker images are the basis of containers. Each time you’ve used docker runyou told it which image you wanted. In the previous sections of the guide youused Docker images that already exist, for example the ubuntu image and thetraining/webapp image.

You also discovered that Docker stores downloaded images on the Docker host. Ifan image isn’t already present on the host then it’ll be downloaded from aregistry: by default the .

In this section you’re going to explore Docker images a bit moreincluding:

  • Managing and working with images locally on your Docker host.
  • Creating basic images.
  • Uploading images to .

Listing images on the host

Let’s start with listing the images you have locally on our host. You cando this using the docker images command like so:

$ docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZEubuntu              14.04               1d073211c498        3 days ago          187.9 MBbusybox             latest              2c5ac3f849df        5 days ago          1.113 MBtraining/webapp     latest              54bb4e8718e8        5 months ago        348.7 MB

You can see the images you’ve previously used in the user guide.Each has been downloaded from when youlaunched a container using that image. When you list images, you get three crucial pieces of information in the listing.

  • What repository they came from, for example ubuntu.
  • The tags for each image, for example 14.04.
  • The image ID of each image.

Tip:You can use or the to display

visualizations of image data.

A repository potentially holds multiple variants of an image. In the case ofour ubuntu image you can see multiple variants covering Ubuntu 10.04, 12.04,12.10, 13.04, 13.10 and 14.04. Each variant is identified by a tag and you canrefer to a tagged image like so:

ubuntu:14.04

So when you run a container you refer to a tagged image like so:

$ docker run -t -i ubuntu:14.04 /bin/bash

If instead you wanted to run an Ubuntu 12.04 image you’d use:

$ docker run -t -i ubuntu:12.04 /bin/bash

If you don’t specify a variant, for example you just use ubuntu, then Dockerwill default to using the ubuntu:latest image.

Tip:You recommend you always use a specific tagged image, for exampleubuntu:12.04. That way you always know exactly what variant of an image isbeing used.

Getting a new image

So how do you get new images? Well Docker will automatically download any imageyou use that isn’t already present on the Docker host. But this can potentiallyadd some time to the launch of a container. If you want to pre-load an image youcan download it using the docker pull command. Suppose you’d like todownload the centos image.

$ docker pull centosPulling repository centosb7de3133ff98: Pulling dependent layers5cc9e91966f7: Pulling fs layer511136ea3c5a: Download completeef52fb1fe610: Download complete. . .Status: Downloaded newer image for centos

You can see that each layer of the image has been pulled down and now youcan run a container from this image and you won’t have to wait todownload the image.

$ docker run -t -i centos /bin/bashbash-4.1#

Finding images

One of the features of Docker is that a lot of people have created Dockerimages for a variety of purposes. Many of these have been uploaded to. You can search these images on the website.

转载地址:http://bnhbi.baihongyu.com/

你可能感兴趣的文章
剑指offer算法题分析与整理(三)
查看>>
部分笔试算法题整理
查看>>
Ubuntu 13.10使用fcitx输入法
查看>>
pidgin-lwqq 安装
查看>>
mint/ubuntu安装搜狗输入法
查看>>
C++动态申请数组和参数传递问题
查看>>
opencv学习——在MFC中读取和显示图像
查看>>
retext出现Could not parse file contents, check if you have the necessary module installed解决方案
查看>>
pyQt不同窗体间的值传递(一)——对话框关闭时返回值给主窗口
查看>>
linux mint下使用外部SMTP(如网易yeah.net)发邮件
查看>>
北京联通华为光猫HG8346R破解改桥接
查看>>
python使用win32*模块模拟人工操作——城通网盘下载器(一)
查看>>
python append 与浅拷贝
查看>>
Matlab与CUDA C的混合编程配置出现的问题及解决方案
查看>>
2017阿里内推笔试题--算法工程师(运筹优化)
查看>>
python自动化工具之pywinauto(零)
查看>>
python一句话之利用文件对话框获取文件路径
查看>>
PaperDownloader——文献命名6起来
查看>>
PaperDownloader 1.5.1——更加人性化的文献下载命名解决方案
查看>>
如何将PaperDownloader下载的文献存放到任意位置
查看>>