@TOC


Recommend personal Docker articles, very detailed

【 Docker container 1】Dockerd details and installation



Build Jdk, Mysql, Nginx, Redis, Tomcat environment based on Docker in one minute



Deploy the SpringBoot project based on Docker



【 Docker container 4】 Build Docker private server based on Docker, and how to use Docker private server details



How to build Maven private server based on Docker, and how to use Maven private server



Build GitLab management code based on Docker



Automatic construction, deployment, testing and monitoring of projects based on Docker installation Jenkins



1. What is the Nexus

Nexus is a powerful Maven repository manager that greatly simplifies maintenance of its own internal repositories and access to external repositories. With Nexus you can have complete control over accessing and deploying each Artifact in your maintained repository in only one place. We can set up a Maven private server on a local area network to deploy third party common artifacts or act as a proxy for remote repositories on the local network.

2. Why Docker private server?

Custom Docker mirror, such as micro you deploy services, you set your environment, the project with good packaged into the mirror, throw into private warehouse, deployment clusters directly pull down directly use, does not require any configuration, not happy, safe and quick, general enterprises are not allowed to put the mirror in the network, for the sake of safety

3. Build Nexus based on Docker to build Docker private server

1. Download the Nexus3 image

Be sure to build a Docker Linux environment yo, don’t know can see my previous article

Enter: docker pull sonatype/ Nexus3Copy the code

2. Start a container using the image

docker run -d --name nexus  --restart=always -p 5000:5000 -p 8081:8081 sonatype/nexus3
Copy the code

Note: Port 5000 is the service port for the mirror warehouse. Port 8081 is the service port for the Nexus

3. Log in to the Nexus server

Turn off the firewall and access http://ip:8081 Nexus startup container. It takes a while.

Note: The default account password is admin/ Admin123

Damn, I can’t get in. Just change the password

4. Change the initial password and log in to the Nexus server

If the user name or password is incorrect, go to the admin.password file to see the initial password.

Enter :(find password file) find / -name 'admin.password'Copy the code

Enter: cat Enter the file location looked up above to get the passwordCopy the code

That jumble is the code. Then his login to change the password to log in again, after logging in, he will let you change the user name and password by default, note that both are typed new passwordJust go to the next step

5. Create the Docker repository

1. Create the General Docker library

By default, the warehouse configuration screen is displayed. Select Blob Stores to create storage space Click create in blue and it’s ok

2. Create a Docker repository

Go to the Settings screen, select Repositories, and click Create Repository, as shown below:Select the warehouse type. Docker has three types, namely group, Hosted, and Proxy. Only the Hosted type is demonstrated here, so select Docker (Hosted) as shown below:Note: The Docker image warehouse type is explained as follows: Hosted: local storage, which provides the same local private server functions as the Docker official warehouse proxy: Provides the type of proxy for other warehouses, such as the Docker central warehouse Group: A group type that essentially combines multiple warehouses into one address

Docker API V1 is supported, and then create repository. Docker API V1 is supported. As shown in figure

So that’s the last paragraph

6. Use the current Linux to specify the connection to the Docker private library

Since we did not use encrypted HTTPS for access during the test, we need to add a startup parameter of docker and specify the address of the private library as follows:

Vi /etc/docker-daemon. json {"insecure-registries":["http://120.77.0.58:5000"]}Copy the code

Note: The IP address above is your Own Linux IP address. In the Linux command, vi means to edit the file, and then enter I to enter the editing mode. After adding the above code, enter ESC to exit the editing mode, and then enter :wq to save and exit. Remember that port 5000 is accessible from the Internet

Run the systemctl restart command to restart the docker processCopy the code

Check docker information: Docker info. It works normally if the following output is displayedCopy the code

7. Log in to the private library using the current Linux

Realms(login, pull, push)

I need to move these two to the right and click Save

2.Docker enters the address to log in

To use the private library for uploading and downloading requires login to connect to Nexus :(local login does not require password)

Enter the address to log in: Docker login http://120.77.0.58:5000/repository/dockertest/ there is a way of login docker login -u admin - p admin123 120.77.0.58: / repository/dockertest / 5000Copy the code

Note: the above IP address is the Linux IP address of the Docker container, and the other one is the repository name.

Login successful

8. Use another Linux system to connect to the private Docker repository

I have changed a Linux here, which is the Linux system of Docker

Note: You also need to perform step 6 because Https is not configured

1. Specify the address for connecting to the private library

Vi /etc/docker-daemon. json {"insecure-registries":["http://120.77.0.58:5000"]}Copy the code

2. Restart the Docker process

systemctl restart docker
Copy the code

3.Docker enters the address to log in

Enter address: Docker login http://120.77.0.58:5000/repository/dockertest/ there is a way of login docker login -u admin - p admin123 120.77.0.58: / repository/dockertest / 5000Copy the code

9. Upload image to Docker private server using current or other Linux

1. Check the available mirrors

Enter the command to view images: Docker imagesCopy the code

Uploading an image consists of four steps

1: login: docker login -u admin - p admin123 120.77.0.58:5000 / repository/dockertest / 2. Docker tag Container ID 120.77.0.58:5000/redis 3. Upload image docker Push 120.77.0.58:5000/ Redis 4. Logout of docker logout 120.77.0.58:5000Copy the code

successful

Docker downloads images from private servers

I’ve changed a server here, but I could have just deleted it and downloaded it and remember to do step 6, because there’s no SSL certificate, that’s what you do with HTTP

Login: docker login -u admin - p admin123 120.77.0.58:5000 / repository/dockertest/download: Docker pull 120.77.0.58:5000/redis View image: Docker imagesCopy the code

successful