Docker intranet builds DNS and uses domain name access instead of ip:port operation

Docker intranet builds DNS and uses domain name access instead of ip:port operation

For example, if I have a Jenkins server in my intranet, I have to remember its IP and port number if I want to access it. I can remember one service, but if I have more than one, I may need a domain name that is easy to remember to record some intranet services.

Step 1: Prepare the Docker environment

Step 2: Download the image

docker pull andyshinn/dnsmasq:2.75

Step 3: Run dnsmasq

#Background start docker run -d -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN --name dns-server andyshinn/dnsmasq:2.75

#Enter the container docker exec -it dns-server /bin/sh

#Create proxy file-add external dns
vi /etc/resolv.dnsmasq

nameserver 114.114.114.114
nameserver 8.8.8.8

#Create a new local resolution rule configuration-add local resolution rule#Note: The ip here should be filled in with the ip of the host where docker is located
vi /etc/dnsmasqhosts
.168.3.54 jenkins.ean.com test1.ean.com
.168.3.54 redis.ean.com

#Append the two files we just configured #vi /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq
addn-hosts=/etc/dnsmasqhosts

#Exit the container & restart exit

docker restart dns-server

Step 4: Set up nginx

Be sure to install nginx as a domain name reverse proxy on 3.54

server{
 listen 80;
 server_name jenkins.ean.com;
 proxy_set_header Host $host;
 location /{
  proxy_pass http://192.168.3.54:8060;
 }
}

Additional knowledge: docker pull private warehouse image

1. Docker pull private warehouse error

The http server gave http response to the https client

Due to different Docker versions, you can try the following two methods: (configuration on the client)

(1) Method 1: By configuring /etc/docekr/daemon.json

vim /etc/docker/daemon.json
{
 "insecure-registry": ["172.16.12.196:5000"] (warehouse address)
}

(2) Method 2: By configuring /etc/sysconfig/docker

vim /etc/sysconfig/docker

INSECURE_REGISTRY = "--insecure-registry 172.16.12.196:5000"

The above article about setting up DNS in Docker intranet and using domain name access instead of ip:port is all I have to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Is Docker a perfect PaaS alternative?
  • Will the deprecated Docker be replaced by Podman?

<<:  JS implementation of carousel carousel case

>>:  Markup Language - Anchor

Recommend

How to make a div height adaptive to the browser height

This old question has troubled countless front-end...

The easiest way to reset mysql root password

My mysql version is MYSQL V5.7.9, please use the ...

How MySQL uses transactions

Basics A transaction is an atomic operation on a ...

Detailed explanation of Windows time server configuration method

Recently, I found that the company's server t...

Mysql 8.0.18 hash join test (recommended)

Hash Join Hash Join does not require any indexes ...

How to manually install MySQL 5.7 on CentOS 7.4

MySQL database is widely used, especially for JAV...

Solution to the problem that Docker container cannot access Jupyter

In this project, the Docker container is used to ...

How to use Dockerfile to create a mirror of the Java runtime environment

The current environment is: Centos 7.5 docker-ce ...

Summary of various methods of implementing article dividing line styles with CSS

This article summarizes various ways to implement...

How to create LVM for XFS file system in Ubuntu

Preface lvm (Logical Volume Manager) logical volu...

Detailed explanation of the basic implementation principle of MySQL DISTINCT

Preface DISTINCT is actually very similar to the ...

7 cool dynamic website designs for inspiration

In the field of design, there are different desig...

Implementation of multiple instances of tomcat on a single machine

1. Introduction First of all, we need to answer a...