DockerInAction-Software installation simplified

来源:互联网 发布:bilibili视频编辑软件 编辑:程序博客网 时间:2024/06/05 05:33

3.1

Identifying software

An image is a file. It holds files that will be available to containers created from it and metadata about the image. This metadata contains information about relationships between images, the command history for an image, exposed ports, volume definitions, and more.

Images have identifiers, so they could be used as a name and version for the software, but in practice it’s rare to actually work with raw image identifiers. They are long, unique sequences of letters and numbers. Each time a change is made to an image, the image identifier changes.

What is a repository?

A repository is a named bucket of images. The name is similar to a URL. A repository’s name is made up of the name of the host where the image is located, the user account that owns the image, and a short name.

3.2

A repository can hold several images. Each of the images in a repository is identified uniquely with tags.

Using tags

Tags are both an important way to uniquely identify an image and a convenient way to create useful aliases. Whereas a tag can only be applied to a single image in a repository, a single image can have several tags.

Finding and installing software

Docker Hub is a registry and index with a website run by Docker Inc. When you issue a docker pull or docker run command without specifying an alternative registry, Docker will default to looking for the repository on Docker Hub.

Docker Hub from the command line

Docker Hub also provides a set of official repositories that are maintained by Docker Inc. or the current software maintainers. These are often called libraries.

Using alternative registries

An alternative registry:

docker pull quay.io/dockerinaction/ch3_hello_registry:latest

The full pattern is as follows:

[REGISTRYHOST/][USERNAME/]NAME[:TAG]

Images as files

Figure 3.5 demonstrates docker save by creating a file from BusyBox.

3.5

Installing from a Dockerfile

A Dockerfile is a script that describes steps for Docker to take to build a new image.

Installation files and isolation

Image layers in action

The two images you’re going to install are dockerinaction/ch3_myapp and dockerinaction/ch3_myotherapp.

docker pull dockerinaction/ch3_myappdocker pull dockerinaction/ch3_myotherapp

When you installed ch3_myapp, Docker determined that it needed to install the openjdk-6 image because it’s the direct dependency (parent layer) of the requested image. When Docker went to install that dependency, it discovered the dependencies of that layer and downloaded those first. Once all the dependencies of a layer are installed, that layer is installed.

By default, the docker images command will only show you repositories.

  • dockerinaction/ch3_myapp
  • dockerinaction/ch3_myotherapp
  • java:6
docker rmi \    dockerinaction/ch3_myapp \    dockerinaction/ch3_myotherapp \    java:6

The docker rmi command allows you to specify a space-separated list of images to be removed.

Layer relationships

3.7

In figure 3.7, the parents of the common Java 6 image are labeled using the first 12 digits of their UID. These layers contain common libraries and dependencies of the Java 6 software. Docker truncates the UID from 65 (base 16) digits to 12 for the benefit of its human users.

Container file system abstraction and isolation

Docker uses a variety of union file systems and will select the best fit for your system.

0 0