Talk briefly about the use of Docker mirrors

  • 2020-05-17 07:00:34
  • OfStack

In the previous article, setting up an Nginx server in Docker, we showed you how to quickly set up a functional Nginx server. This time we'll show you how to use Docker mirroring (Docker Image). Includes 3 parts:

Install the Docker image from Docker Hub or another image source Install the Docker image from Image file Make an Docker mirror from Docker file

Find the Docker image

Step 1 of installing Docker images is to find the list of Docker images you need and type:

docker search mysql

If permission issues arise, add sudo first:

sudo docker search mysql

The query returns 1 list:


NAME            DESCRIPTION                   STARS   OFFICIAL  AUTOMATED
mysql           MySQL is a widely used, open-source relati...  2981   [OK]
mysql/mysql-server     Optimized MySQL Server Docker images. Crea...  194         [OK]
centurylink/mysql     Image containing mysql. Optimized to be li...  46          [OK]
sameersbn/mysql                              36          [OK]
jdeathe/centos-ssh-mysql  CentOS-6 6.8 x86_64 / MySQL.          8          [OK]
appcontainers/mysql    Centos/Debian Based Customizable MySQL Con...  8          [OK]
marvambass/mysql      MySQL Server based on Ubuntu 14.04       6          [OK]
drupaldocker/mysql     MySQL for Drupal                2          [OK]
azukiapp/mysql       Docker image to run MySQL by Azuki - http:...  2          [OK]
yfix/mysql         Yfix docker built mysql             2          [OK]
alterway/mysql       Docker Mysql                  2          [OK]
frodenas/mysql       A Docker Image for MySQL            2          [OK]
andreluiznsilva/mysql   A extension of the offical MySQL container...  1          [OK]
phpmentors/mysql      MySQL server image               1          [OK]
sin30/mysql        MySQL images with my own config files.     1          [OK]
tozd/mysql         MySQL (MariaDB fork) Docker image.       0          [OK]
nanobox/mysql       MySQL service for nanobox.io          0          [OK]
...

The list contains all the MySQL images, where:

The NAME field is the name of the image The DESCRIPTION field is a simple description of the image The number of STARS reflects how much users like it If the OFFICIAL field is OK, it means that the image is officially provided and can be trusted The AUTOMATED field, if OK, represents that the image is based on public scripting and can be trusted If both OFFICIAL and AUTOMATED are not OK, you need to be extra careful when using them. These images may contain malware, but they can be used for personal, non-sensitive data.

In addition, you can also access https: / / hub docker. com /, to search through Web mirror you need.

Download the Docker image

When you find the right mirror image, you can do so by:

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

To download, with the following options in square brackets:

docker pull mysql

Export the Docker image

You can export the local image as a file, as we just downloaded the MySQL image:

docker save -o mysql.tar mysql

Export our MySQL image to mysql.tar.

Import the Docker image

If there is an export, there is an import. The import command is:

docker load -i mysql.tar

Import our MySQL image.

Delete the Docker image

In order to save disk space, sometimes we need to delete the Docker image file that we don't need. First, we need to check the Docker image file that we have:

docker images

Then remove the unwanted image to free up disk space:

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

Compile the Docker image with Docker File

We will talk about Docker File later. Suppose you have a file named Dockerfile. The command for compiling Docker is:

docker build -f Dockerfile .

On success, an Docker image will be created in the current path.

Summary

We briefly introduced the use of Docker mirror. This should give you a deeper understanding of Docker mirroring.


Related articles: