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

React mouse multi-selection function configuration method

Generally, lists have selection functions, and si...

Tutorial on installing mysql5.7.23 on Ubuntu 18.04

This article shares with you the specific method ...

Should I use distinct or group by to remove duplicates in MySQL?

Preface About the performance comparison between ...

Uncommon but useful tags in Xhtml

Xhtml has many tags that are not commonly used but...

Detailed explanation of the API in Vue.js that is easy to overlook

Table of contents nextTick v-model syntax sugar ....

How to delete node_modules and reinstall

Table of contents Step 1: Install node_modules in...

How to deploy a simple c/c++ program using docker

1. First, create a hello-world.cpp file The progr...

HTML form tag tutorial (3): input tag

HTML form tag tutorial, this section mainly expla...

Four ways to combine CSS and HTML

(1) Each HTML tag has an attribute style, which c...

Summary of ten Linux command aliases that can improve efficiency

Preface Engineers working in the Linux environmen...

Methods and steps to build nginx file server based on docker

1. Create a new configuration file docker_nginx.c...

Analyzing ab performance test results under Apache

I have always used Loadrunner to do performance t...

MySQL data insertion optimization method concurrent_insert

When a thread executes a DELAYED statement for a ...