This simple setup allows your Docker image to take off

Keywords: Java Docker nexus SDK github

This article has been included GitHub There are also Internet factory interview questions, interview strategies, efficient learning materials and so on

1. Preface

Docker is cool to use, especially when used in DevOps practice.However, when you pull a mirror at home or locally, you often encounter constipation - either slowly or intermittently, or the connection timed out!

It's a nightmare when we have a big mirror (like someone losing a Warcraft bag in their code)!So how do you solve this problem?Next, we will solve this problem mainly from the following aspects:

  • Using Mirror Accelerators
  • Source Change
  • Make your own mirror and push it to domestic warehouse
  • Build your own near mirror warehouse
  • Last trick (confidentiality)

2. Mirror Accelerators

Accelerators can be sacrificed for playing online game cards. Mirror-pulling commonly has related accelerators.Mirror Accelerators are basically available from domestic cloud manufacturers:

Docker Hub Mirror Accelerator List

How do I use the Mirror Accelerator?

Docker Hub Mirror Accelerator Configuration

Linux systems can execute the following shells:

Once configured, you can check the validity of the docker info command:

What if it's Windows 10?You can configure it at the interface shown in the following figure:

Windows 10 Configuration

3. Source Change

Accelerators are cool to use, but most of the time, even with an accelerometer configured, some mirrors don't work well (possibly related to the accelerometer's international bandwidth), so you have to switch sources.Accelerators are not everything, especially when your mirror is large.Then you have to find the right source.

For example, the SDK image of.NET Core, we can use the Azure China mirror source uniformly, as shown in the table below, we can see that ""The corresponding agent in China is"":

So we can use ""instead of the official""Source:

# docker pull
docker pull

As shown in the code above, we will change the source of Azure International to that of Azure China, and the pulling speed will be fast.Changing the source means that we also need to modify Dockerfile's commands:

#FROM AS build
#Modify to Azure China Mirror
FROM AS build

4. Pushing self-made mirrors into domestic warehouses

What if there is no source?Can't it be cold?Do it yourself.It can be built overseas based on GitHub hosting, Azure DevOps and Docker hub, and then pushed into domestic mirror warehouses.

Relevant Mirror Label Description

Then simply replace it with your own source in the Dockerfile to enjoy a quick flight:

FROM AS base

Here's a trick to share: apt packaging on Linux is often very slow and unreliable, and sometimes domestic agents are unreliable, so consider using an overseas build to mirror it.

5. Build your own near mirror warehouse

Server bandwidth is not good, local network is not good, what can I do?What else can you do? Build your own warehouse.It's recommended that you use nexus, which hosts packages like Docker, Nuget, Jar, npm, Bower, and so on. It's hardly too sharp.How to build?Yaml often takes the following exams:

apiVersion: apps/v1beta2
kind: Deployment
    k8s-app: nexus
  name: nexus
  namespace: default
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
      k8s-app: nexus
    type: Recreate
        k8s-app: nexus
      - image: sonatype/nexus3
        imagePullPolicy: IfNotPresent
        name: nexus
            cpu: "2"
            memory: 5024Mi
            cpu: 10m
            memory: 256Mi
        - mountPath: /nexus-data
          name: data
      restartPolicy: Always
      nodeName: k8s-node1 #Force constraints to dispatch Pod s to specified Node nodes
      terminationGracePeriodSeconds: 30 #The wait time (in seconds) at the end of a Pod
        - name: data
          hostPath:   #Use Host Directory
            path: /var/nexus
      hostNetwork: true
apiVersion: v1
kind: Service
  name: nexus
  namespace: default
  - name: tcp-8081-8081
    nodePort: 30081
    port: 8081
    protocol: TCP
    targetPort: 8081
  - name: tcp-8082-8082
    nodePort: 30082
    port: 8082
    protocol: TCP
    targetPort: 8082
  - name: tcp-8083-8083
    nodePort: 30083
    port: 8083
    protocol: TCP
    targetPort: 8083
  - name: tcp-8084-8084
    nodePort: 30084
    port: 8084
    protocol: TCP
    targetPort: 8084
  - name: tcp-8085-8085
    nodePort: 30085
    port: 8085
    protocol: TCP
    targetPort: 8085
  - name: tcp-8086-8086
    nodePort: 30086
    port: 8086
    protocol: TCP
    targetPort: 8086
    k8s-app: nexus
  sessionAffinity: None
  type: NodePort

6. Final Solutions

Not yet. Copy it with a U disk.Don't say you know me.You don't believe you can copy it through a U drive?You can learn about the following two commands:

  • docker save
  • docker load

Posted by oneday on Mon, 29 Jun 2020 16:19:02 -0700