Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of Windows using Swarm native Docker cluster to step on crater

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Environment:

Role machine name operating system IP remarks MaterWeb30Windows Server 2016 GUI192.168.2.30 install the latest recommended patch NodeWeb31Windows Server 2016 Core192.168.2.31 install the latest recommended patch NodeWeb32Windows Server 2016 Core192.168.2.32 install the latest recommended patch

Pit 1: Windows Server 2016 Core

1. Operating system partition pit

Since the Windows images we use are all based on the microsoft/windowsservercore size of about 10 GB, we also need to install IIS, aspnet, and so on. In addition, if image export is involved, it will also take up space on disk C, so for Docker, it is recommended that the space of disk C be not less than 60 GB, or simply divide into disks C.

Solution to trampling: when there is a lot of spare space on the hard disk, you can mount the C:\ ProgramData\ docker\ windowsfilter folder in the form of a folder.

two。 How to set the machine IP and machine name and open the remote desktop on the command line

Execute sconfig from the CMD command prompt. It is recommended to enable remote desktop command input.

3. Be sure to install the latest Windows patch before installing Docker

Method: sconfig--- > 6) download and install updates-> R) search for only recommended updates-> A) install all

4. How to copy files to Windows Server Core, on the command line

Open writable sharing

Cd\

Mkdir share

Net share share=c:\ share / grant:everyone,full

Connection sharing

Net use z:\\ 192.168.2.30\ share password / user:administrator

So it is mapped and shared to Z disk, and the file can be manipulated by entering Z disk.

Delete Shar

Net share c:\ share / del / y

5. How to view files on the Windows command line

Type filename.txt

Append file

Echo 127.0.0.1 web30 >\ windows\ system32\ drivers\ etc\ hosts

6. View Windows processes

Tasklist

7. Kill process

Tskill

Pit 2: Windows 2016 native Docker

1.Windows install Docker

Enter and leave powershell at the command prompt

Install-Module-Name DockerMsftProvider-Repository PSGallery-ForceInstall-Package-Name docker-ProviderName DockerMsftProvider

If the second part prompts you that no patch is installed, you need to install the latest Windows patch, enter step 6 of sconfig

Restart the server after the installation is complete

two。 Configure firewall rules for all servers

TCP port 2377 for cluster management communication

TCP and UDP port 7946 for communication between nodes

TCP and UDP port 4789 for overlay network communication

Netsh advfirewall firewall add rule name= "swm 2377" dir=in action=allow protocol=TCP localport=2377 netsh advfirewall firewall add rule name= "swm 7946" dir=in action=allow protocol=TCP localport=7946netsh advfirewall firewall add rule name= "swm 7946udp" dir=in action=allow protocol=UDP localport=7946netsh advfirewall firewall add rule name= "swm 4789" dir=in action=allow protocol=TCP localport=4789netsh advfirewall firewall add rule name= "swm 4789udp" dir=in action=allow protocol=UDP localport=4789

3. Initialize cluster mode

Execute on Master

C:\ > docker swarm init-- advertise-addr=192.168.2.30-- listen-addr 192.168.2.30VR 2377

Pit: you can initialize the cluster by executing docker swarm init on Linux, but it will get stuck on Windows. You need to specify IP and port on windows.

4. Join the cluster (executed in Web31 and Web32)

Prompt for input above

Docker swarm join\-token SWMTKN-1-1lbjx00s1qsjbjfuoq92f6d95mf41arbhwbkkigmo1smjqs38r-8i0bdakwhc3lvbbog8fnmvgmw\ 192.168.2.30mm 2377

You can join the cluster. Note that it needs to be changed to one line here.

Docker swarm join-- token SWMTKN-1-1lbjx00s1qsjbjfuoq92f6d95mf41arbhwbkkigmo1smjqs38r-8i0bdakwhc3lvbbog8fnmvgmw 192.168.2.30 purl 2377

Pit 1: you can only use one line to join the cluster command, and you cannot use\ to wrap.

Pit 2: be sure to open the appropriate rules in the firewall and open the 2377/TCP, 7946/TCP, 7946/UDP, 4789/TCP, 4789/UDP ports

Pit 3: at present, the test Linux can join the Windows Swarm cluster, and Windows can also join the Linux Swarm cluster. After testing, it is normal for me to add the Linux node to the Windows Swarm cluster, but the Linux Swarm Master manages the Windows node to report an error. I don't know if it has anything to do with the version.

Execute on the Windows Swarm Master node

Docker service create-name=ping-constraint "Node.Platform.OS==Linux"-network=myspace centos ping 127.0.0.1

Note:-- constraint "Node.Platform.OS==Linux" must be double quotation marks, not single quotation marks, otherwise report Error response from daemon: rpc error: code = 2 desc = key''node.Platform.OS' is invalid

5. Service port mapping problem

In the Linux environment, we can pass through the

Docker service create-name web-p 80:80 nginx

After execution, each node can serve through port 80, but not in Windows.

Docker service create-name iis-p cannot be accessed through port 80 after 80:80 microsoft/iis execution

At present, through

Docker service create-name iis-p mode=host,target=80,published=80,protocol=tcp microsoft/iis

And then through docker service ps iis

C:\ Users\ Administrator > docker service ps iisID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTSe118tf9vu15l iis.2 microsoft/iis:latest Web32 Running Running 2 hours ago *: 8090-> 80/tcp

You can see that the container is on the Web32. At this time, you can access it normally by accessing 192.168.2.32, but the host's port 8090 cannot be used.

6.Docker private warehouse configuration

Configure private warehouse

Method 1: change the registry [HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ Docker]

Modify it to C:\ Program Files\ Docker\ dockerd.exe-- run-service-- insecure-registry "192.168.2.234virtual 5000"

Method 2: modify Docker configuration file. It is recommended to modify configuration file.

C:\ ProgramData\ docker\ config\ daemon.json

{

"insecure-registries": ["192.168.2.234VR 5000"]

}

If you don't have this file, you can create it in ASSIC form.

7.Windows Docker opens remote port access

Method 1: modify Docker startup parameters in the registry

C:\ Program Files\ Docker\ dockerd.exe-- run-service-D-H tcp://0.0.0.0:2375-H npipe://

Method 2: modify the Docker daemon.json configuration file

{"hosts": ["tcp://0.0.0.0:2376", "npipe://"]}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report