Main Contents:

  • What is a mirror image
  • Download image Pull
  • Set the download acceleration source
  • Look at mirror
  • Upload image push

📀 What is an image?

An image is a file system that provides the files and parameter configurations needed to run the container. This is equivalent to the installation package you need to download to use a software. It is also equivalent to the ISO file you need to install an operating system.

We can create multiple containers based on a single image.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbcde5ef3a1~tplv-t2oaga2asx-image.image

📥 Download image

If you want to run a Docker container, you can directly download the corresponding image from the Docker Hub, and then create the container through the image. Docker Hub is similar to GitHub, where you can host your own images and download them when you need them.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbcf1682cfb~tplv-t2oaga2asx-image.image

Git git git git git git git git git git git git On the DockerHub, click on the details page and you’ll see a number of download labels that you can use to download the specified version.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbce4646375~tplv-t2oaga2asx-image.image

Download UTunTU 14.04, or click the tag to go to Dockerfile to see details.

Docker image pull utuntu: 14.04

Copy the code

Utuntu’s image will be downloaded

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbce4ab9d8a~tplv-t2oaga2asx-image.image

After downloading an image, you can use the docker image ls command to see which images are available.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbce4a5872d~tplv-t2oaga2asx-image.image

Then create a container and run it with the image:

Docker container run ubuntu: 14.04

# or via image ID

docker container run 6e4f1fe62ff1

Copy the code

🚀 Set the domestic source

Domestic download official source download speed will be relatively slow, sometimes so that people want to cry, so it is best to set up a domestic source address.

The mirrored acceleration address provides a few references that are now used for 163:

  • registry.docker-cn.com
  • hub-mirror.c.163.com
  • 3laho3y3.mirror.aliyuncs.com
  • f1361db2.m.daocloud.io
  • mirror.ccs.tencentyun.com

Configuring the Docker Toolbox

# login host

$ docker-machine ssh default 



Add a local source address

$ sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=[http://hub-mirror.c.163.com](http://hub-mirror.c.163.com/) |g" \

/var/lib/boot2docker/profile 



# Exit the machine

exit 



# to restart the host

$ docker-machine restart default

Copy the code

/etc/docker/daemon.json

# vi /etc/docker/daemon.json

{

    "registry-mirrors": ["http://hub-mirror.c.163.com"]

}

Copy the code

🔍 View image details

The details of the image can be viewed using the inspect command. Such as which ports are open, which environment variables are set, and which commands are ultimately run.

docker container inspect image_id

Copy the code

View the build history of the image:

docker image historyUtuntu: 14.04

Docker image history image_id

Copy the code

Each line represents a layer, and you can see how the image is constructed. Missing represents the middle layer, that is, the temporary image generated when the final image is constructed.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbcf17f1fd8~tplv-t2oaga2asx-image.image

In other words, there are many steps before an image is made, and each step generates a layer. Eventually, all the intermediate steps are merged to get the image that will be used.

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbd0867f2b4~tplv-t2oaga2asx-image.image

📤 upload image

To upload an image, you first need to create a remote label for the local image

Docker Image Tag Python :3.7-alpine looker53/python:3.7-alpine

# you can also use image ID

Docker Image tag e854017DB514 looker53/python:3.7-alpine

Copy the code

Looker53 = looker53 = looker53 = looker53 = looker53 = looker53 = looker53 = looker53

Log in to looker53:

docker login

Copy the code

Then push it to the remote repository with the push command:

docker image push looker53/python:37alpine

Copy the code

Next, you can see the push repository in DockerHub:

https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/5/28/1725bbbd0a154426~tplv-t2oaga2asx-image.image