Wiki source code of Install Docker for Windows
Version 94.1 by Erik Bakker on 2024/02/08 16:43
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{container}}{{container layoutStyle="columns"}}((( | ||
2 | In this microlearning, we will focus on how an on-premises server can be prepared for a eMagiz Deploy agent installation. | ||
3 | |||
4 | Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]]. | ||
5 | |||
6 | == 1. Prerequisites == | ||
7 | |||
8 | * Advanced knowledge of the eMagiz platform | ||
9 | * Good understanding of eMagiz runtimes in general | ||
10 | |||
11 | == 2. Key concepts == | ||
12 | In the new runtime architecture of eMagiz, Docker technology is used to deploy runtimes. eMagiz creates specific runtime images that contain the eMagiz runtime, and can be deployed in dockerized environments. | ||
13 | |||
14 | In the below section the Windows and Linux variants are described in terms of how to prepare the server to allow the eMagiz Deploy agent to be installed. That agent allows to download images from the eMagiz infrastructure. | ||
15 | |||
16 | == 3. On-premises deployments == | ||
17 | |||
18 | ===3.1 General requirements=== | ||
19 | These are the general requirements to allow the installation of the eMagiz Docker agent: | ||
20 | * Ensure access to the following URLs is enabled | ||
21 | ** registry.emagiz.com:443 | ||
22 | ** controlplane.emagiz.com:8000 | ||
23 | ** Preferably the entry should be *.emagiz.com | ||
24 | |||
25 | ===3.2 Installation requirements Linux=== | ||
26 | Whenever Linux is selected as operating system, the latest version of Ubuntu will work. Other Linux distributions will also work such as Debian or Red Hat. | ||
27 | **Step 1: Install linux distribution** | ||
28 | Follow the relevant steps in section 3.4 | ||
29 | |||
30 | **Step 2: Install eMagiz Deploy Agent** | ||
31 | Install the eMagiz Deploy agent as can be found in this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.eMagiz Runtime Management.intermediate-runtime-management-deploy-agent.WebHome||target="blank"]] | ||
32 | |||
33 | ===3.3 Installation requirements Windows Server 2022 === | ||
34 | |||
35 | {{info}}Please note that this section also applies to Windows Server 2019 version >1806{{/info}} | ||
36 | |||
37 | The steps below will install a linux subsystem under Windows. In that Linux system, Docker and Java will be installed. Please note that the Windows server needs to be able to run Virtualized (either via BIOS setting or via Nested Virtualization). | ||
38 | |||
39 | **Step 1: Install linux distribution** | ||
40 | |||
41 | {{code language="cmd"}} | ||
42 | wsl --install -d Ubuntu | ||
43 | sudo apt-get update | ||
44 | sudo apt install --no-install-recommends apt-transport-https ca-certificates curl gnupg2 | ||
45 | . /etc/os-release | ||
46 | {{/code}} | ||
47 | |||
48 | **Step 2: Configure linux system** | ||
49 | Please see section 3.4 for these these steps | ||
50 | |||
51 | **Step 3: Update wsl config file ** | ||
52 | In this step we need to add or update the WSL config file that manages the resources of the Linux subsystem. Important resources to manage are the assigned memory and number of processors. For memory we recommend to review the mempory settings for the runtime that need to run on this server and add 762 MB to the total value of the heap and non-heap of these runtimes. For processor we recommend to set the value to 2 - depending on the amount of processors available on that machine | ||
53 | |||
54 | First, locate the config file or add it to the location %USERPROFILE%. The name should be .wslconfig (no extension) | ||
55 | |||
56 | {{code language="cmd"}} | ||
57 | #Add following lines | ||
58 | |||
59 | # Settings apply across all Linux distros running on WSL 2 | ||
60 | [wsl2] | ||
61 | # Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB | ||
62 | memory=16GB | ||
63 | # Sets the VM to use two virtual processors | ||
64 | processors=2 | ||
65 | {{/code}} | ||
66 | |||
67 | **Step 4: Auto start the linux subsystem when Windows server restarts ** | ||
68 | |||
69 | {{code language="cmd"}} | ||
70 | * Press Windows+R | ||
71 | * Type shell:startup and press enter | ||
72 | * Add or update file start_wsl.bat | ||
73 | * Add following line into the document and save file | ||
74 | * wsl sudo /usr/bin/dockerd | ||
75 | {{/code}} | ||
76 | |||
77 | **Step 5: Install eMagiz Deploy Agent** | ||
78 | Install the eMagiz Deploy agent as can be found in this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.eMagiz Runtime Management.intermediate-runtime-management-deploy-agent.WebHome||target="blank"]]. | ||
79 | |||
80 | ===3.4 Installation steps to configure Linux subsystem === | ||
81 | |||
82 | **Step 1: Install Docker ** | ||
83 | |||
84 | {{code language="cmd"}} | ||
85 | curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo tee /etc/apt/trusted.gpg.d/docker.asc | ||
86 | echo "deb [arch=amd64] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list | ||
87 | sudo apt update | ||
88 | sudo apt install docker-ce docker-ce-cli containerd.io | ||
89 | {{/code}} | ||
90 | |||
91 | {{info}} | ||
92 | Requires ~335 Mb space to install | ||
93 | {{/info}} | ||
94 | |||
95 | **Step 3: Ensure Docker is autostarted with WSL ** | ||
96 | |||
97 | {{info}} | ||
98 | This remark is valid for Windows based installations only | ||
99 | {{/info}} | ||
100 | |||
101 | {{code language="cmd"}} | ||
102 | nano .bashrc | ||
103 | |||
104 | #Add following lines to bashrc | ||
105 | DOCKER_DISTRO="Ubuntu" | ||
106 | DOCKER_LOG_DIR=$HOME/docker_logs | ||
107 | mkdir -pm o=,ug=rwx "$DOCKER_LOG_DIR" | ||
108 | /mnt/c/Windows/System32/wsl.exe -d $DOCKER_DISTRO sh -c "nohup sudo -b dockerd < /dev/null > $DOCKER_LOG_DIR/dockerd.log 2>&1" | ||
109 | {{/code}} | ||
110 | |||
111 | **Step 4: Add user to Docker group ** | ||
112 | |||
113 | {{code language="cmd"}} | ||
114 | sudo visudo | ||
115 | |||
116 | #Add following lines | ||
117 | |||
118 | # Don't ask for password | ||
119 | %docker ALL=(ALL) NOPASSWD: /usr/bin/dockerd | ||
120 | {{/code}} | ||
121 | |||
122 | **Step 5: Ensure safe IP range for WSL ** | ||
123 | |||
124 | {{info}} | ||
125 | This remark is valid for Windows based installations only | ||
126 | {{/info}} | ||
127 | |||
128 | This step ensures that the IP address range of the machine doesn't conflict with any IP address of the Linux subsystem. Below the recommended values depending on the range which can be filled in the value <ip-address> below: | ||
129 | * 10.0.0.1/8 | ||
130 | ** advised value 10.25.0.1/16 | ||
131 | * 172.16.0.1/12 | ||
132 | ** advised value 172.16.0.1/16 | ||
133 | * 192.168.0.1/16 | ||
134 | ** advised value 192.168.0.1/16 | ||
135 | |||
136 | {{code language="cmd"}} | ||
137 | sudo nano /etc/docker/daemon.json | ||
138 | |||
139 | #Add following lines | ||
140 | |||
141 | {"bip": "<ip-address>"} | ||
142 | {{/code}} | ||
143 | |||
144 | |||
145 | ===3.5 Installation requirements Windows Server 2019 version 1806=== | ||
146 | |||
147 | {{warning}}Please note that this section is under construction. Please contact us at productmanagement@emagiz.com{{/warning}} | ||
148 | |||
149 | These are the requirements to allow the installation of the eMagiz Docker agent: | ||
150 | * Enable Hyper-V in Windows Server | ||
151 | ** Go to Server Manager, Manage (top right), enable roles and features, select the desired roles and server selections. In the Features section, enable Hyper-V. | ||
152 | ** Restart windows | ||
153 | * Cross check is WSL 2.0 is installed | ||
154 | ** Use this command to get WSL 2.0: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | ||
155 | * Please follow the instructions for preparing a Windows 2022 installation in section 3.3 | ||
156 | |||
157 | {{info}} | ||
158 | * Install Docker Desktop on the Windows Server | ||
159 | ** Please refer to this link: https://www.docker.com/products/docker-desktop/ | ||
160 | ** Restart windows | ||
161 | * Update Docker Desktop configuration | ||
162 | ** Go to settings, and enable ‘Expose daemon on tcp://localhost:2375’ without TLS | ||
163 | ** Restart Docker | ||
164 | * Open Powershell as Administrator | ||
165 | ** Execute "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine | ||
166 | ** Execute Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | ||
167 | ** Execute curl.exe -L -o ubuntu-2004.appx https://aka.ms/wslubuntu2004 | ||
168 | ** Execute Add-AppxPackage .\ubuntu-2004.appx | ||
169 | *** If errors occur, please consult https://learn.microsoft.com/en-us/windows/wsl/install-on-server. Rename the file to a zip, expand it, and add it to the path variable. | ||
170 | * Ubuntu should now be a runnable program (press windows key, type ubuntu) | ||
171 | * Open the ubuntu terminal, and finish the installation. | ||
172 | ** After installation, execute: export DOCKER_HOST=tcp://localhost:2375 | ||
173 | * Go to the next section around installing the eMagiz Docker agent | ||
174 | {{/info}} | ||
175 | |||
176 | ===3.6 Installation requirements Windows Server 2012 R2 === | ||
177 | |||
178 | {{warning}}Please note that this section is under construction. Please contact us at productmanagement@emagiz.com{{/warning}} | ||
179 | |||
180 | These are the requirements to allow the installation of the eMagiz Docker agent: | ||
181 | * Install & enable Hyper-V in Windows Server | ||
182 | ** Go to Server Manager, Manage (top right), enable roles and features, select the desired roles and server selections. In the Features section, enable Hyper-V. | ||
183 | ** Restart windows | ||
184 | * Download a ubuntu server 18.04 (https://releases.ubuntu.com/18.04/ubuntu-18.04.6-live-server-amd64.iso ) | ||
185 | * Create a VM in HyperV. | ||
186 | ** For this, choose Generation 1, the amount of memory you want to assign to ubuntu and thus to the containers. Please consider the overhead for memory as well (such as OS). | ||
187 | ** Configure a virtual switch. | ||
188 | ** Add a virtual Hard Disk with proper sizing (e.g. 30 GB) | ||
189 | ** Install an operating system from bootable CD/DVD, ISO file | ||
190 | * Install ubuntu downloaded previously on the VM | ||
191 | * Install docker as per official ubuntu documentation (See https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository) on the VM | ||
192 | * Go to the next section around installing the eMagiz agent | ||
193 | |||
194 | == 4. Key takeaways == | ||
195 | |||
196 | * eMagiz uses runtime images to deploy emagiz runtime on dockerized environments. The runtime image holds all the information and components required to run the runtime | ||
197 | * eMagiz has a specific agent that manages the download of that image to the on-premises server | ||
198 | * The firewall of the on-premises environment should allow outgoing traffic without any restriction. In case that is not desirable, eMagiz can provide the addresses and ports needed to setup the right firewall rules. | ||
199 | |||
200 | == 5. Suggested Additional Readings == | ||
201 | |||
202 | * Docker command line cheatsheet: [[image:Main.Images.Microlearning.WebHome@docker-cheatsheet.png]] | ||
203 | |||
204 | )))((({{toc/}}))){{/container}}{{/container}} |