You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Run Docker on Windows 10 *without* Docker Desktop
173
+
Docker changed their licensing model recently and many developers must now use the new subscription-based model to use Docker Desktop tool. However, frequently, developers only use the command-line tools in their day-to-day work and so the Docker Desktop tool is overkill for their needs anyway.
174
+
175
+
This article explains how to run Docker on Windows in a very simple command-line-only configuration. And it works on even relatively old Windows 10 systems, including those with Windows Subsystem for Linux (WSL) 1. Essentially, we will be running the Docker daemon (or "service", if you prefer) in a Virtualbox _or_ Hyper-V virtual machine (VM) and accessing it from our Windows 10 host machine in WSL or PowerShell (or Windows Command Prompt).
176
+
177
+
### What You Need
178
+
To use this configuration, we will use the following environment.
179
+
- Windows 10
180
+
- WSL 1 or WSL 2 with Ubuntu 20.04
181
+
- Virtualbox 6.2 with Ubuntu 20.04 guest **or** Hyper-V with Ubuntu 20.04 guest
182
+
As noted, we can use either Virtualbox or Hyper-V for the virtualization platform. This allows Windows 10 Home users to use this process, even though they do not Hyper-V support on their platform.
183
+
184
+
### Install Ubuntu 20.04 in WSL
185
+
Install Ubuntu 20.04 (or 18.04) in WSL according to the standard installation process. Here is a brief outline of the process.
186
+
1. To install WSL, open PowerShell (or Windows Command Prompt) and run
187
+
```bash
188
+
wsl.exe --install
189
+
```
190
+
2. By default, the WSL installation will install Ubuntu. You can also check for other available distributions and versions:
191
+
```bash
192
+
wsl.exe --list --online
193
+
```
194
+
3. Then, you can install one of the available distributions from this list:
195
+
```bash
196
+
wsl.exe --install -d <distroname>
197
+
```
198
+
where `<distroname>` is the name from the earlier list, such as `ubuntu2004`.
199
+
200
+
### Install Virtualbox or Hyper-V Virtualization Platform
201
+
As explained earlier, you can use *either*[Virtualbox](https://www.virtualbox.org/) or [Hyper-V](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/) virtualization platform, depending on your preference and what is supported in your environment. Simply follow the standard installation process for the selected tool. (Note that you **cannot** use _both_ Virtualbox and Hyper-V simultaneously due to the Hyper-V architecture.)
202
+
-[Installing Virtualbox on Windows Hosts](https://www.virtualbox.org/manual/ch02.html#installation_windows)
203
+
-[Install Hyper-V on Windows 10](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v)
204
+
205
+
### Install Ubuntu Linux Guest in Virtualbox or Hyper-V
206
+
After installing Virtualbox or Hyper-V, you will need to install Ubuntu (or other Debian-based) Linux as a guest operating system (OS) on the virtualization platform. You can install a standard GUI version or a very minimal command-line only version. This guest OS will only run Docker daemon (or "service") process, so the OS GUI is entirely optional.
207
+
208
+
Follow the standard installation process for either Virtualbox or Hyper-V for installing guest OSes. Make sure to allocate at least **2GB** of RAM to the guest.
209
+
-[Creating Your First Virtualbox Virtual Machine](https://www.virtualbox.org/manual/ch01.html#gui-createvm)
210
+
-[Create Virtual Machine with Hyper-V on Windows 10](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/create-virtual-machine)
211
+
212
+
### Install Docker Daemon on Ubuntu Linux Guest in Virtualbox or Hyper-V
213
+
Once you've successfully installed Ubuntu as a guest OS in Virtualbox or Hyper-V, in that Ubuntu instance (and **not** the WSL instance _yet_!), install the Docker daemon application. Again, we will be running the Docker daemon in the _guest_ virtual machine (VM) and accessing it from our Windows 10 _host_ machine.
214
+
215
+
Update the Ubuntu packages.
216
+
```bash
217
+
sudo apt update
218
+
sudo apt upgrade -yy
219
+
```
220
+
221
+
Remove any existing Docker installation from standard Ubuntu repositories. (If you just installed Ubuntu guest OS, it's unlikely that they are installed, but it doesn't hurt to check.)
The installation process creates a `docker` group in Linux. We need to add our user to that group to allow us to run Docker commands without using `sudo`.
236
+
```bash
237
+
sudo usermod -a -G docker ${USER}
238
+
```
239
+
You must close the terminal window and open a new one (or log out and log back in, if you are using a console/command-prompt only VM) to get a session in which your user belongs to the `docker` group. To confirm, run the `groups` command and ensure that `docker` is included in the list (it will probably be the last one).
240
+
241
+
To verify that everything is working properly, while still in our Linux guest VM, run `docker info`. You should see some output divided up into `Client` and `Server` sections. See the [`docker info`](https://docs.docker.com/engine/reference/commandline/info/) command documentation for details and examples.
242
+
243
+
### Configure Docker Daemon for External Access on Ubuntu Linux Guest in Virtualbox or Hyper-V
244
+
Now that the Docker daemon is installed and working, we need to make it accessible outside of the Virtualbox or Hyper-V guest OS. For our case, to simplify things, we will configure it **without** encryption. Obviously, this involves some risk, but presumably, we will only be accessing from within the same machine. You can learn more about this in the [Docker security documentation](https://docs.docker.com/engine/security/#docker-daemon-attack-surface).
245
+
246
+
Create a [systemd](https://en.wikipedia.org/wiki/Systemd) service directory for our configuration and create the daemon (service) configuration file.
Refresh the `systemd` configuration and restart Docker.
260
+
```bash
261
+
sudo systemctl daemon-reload
262
+
sudo systemctl restart docker
263
+
```
264
+
265
+
Presumably, you won't receive any errors on restart. In any case, you can check that the Docker daemon restarted (is running) by running `sudo systemctl status docker`, if you like.
266
+
267
+
Basically, this configuration allows local connections from within the Virtualbox or Hyper-V guest OS VM via `-H unix://` and from **any** external client over TCP on port 2375 via `-H tcp://0.0.0.0:2375`.
268
+
269
+
### Determine the IP Address of Ubuntu Linux Guest in Virtualbox or Hyper-V
270
+
The final step involving the Ubuntu Linux guest OS in Virtualbox or Hyper-V is to determine its IPv4 address. We need this IP address to use on the host (WSL or PowerShell) to connect to the Docker daemon remotely.
271
+
272
+
273
+
274
+
275
+
276
+
### References
277
+
[Use Docker for Windows in WSL1](https://pscheit.medium.com/use-docker-for-windows-in-wsl-8fc96ece67c8)
278
+
[How to run docker on Windows without Docker Desktop](https://dev.to/_nicolas_louis_/how-to-run-docker-on-windows-without-docker-desktop-hik)
279
+
[Setting Up Docker for Windows and WSL to Work Flawlessly](https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly)
280
+
[Docker Tip #73: Connecting to a Remote Docker Daemon](https://nickjanetakis.com/blog/docker-tip-73-connecting-to-a-remote-docker-daemon)
## Install Python `cryptography` package on Windows 10
284
+
The Python [`cryptography`](https://cryptography.io/) package depends on several external open-source libraries for implementation of the cryptographic algorithms, including the OpenSSL library. Accordingly, installation of the package requires that some of these libraries be compiled from source during the installation process.
285
+
286
+
Recently, the library has moved to using [Rust](https://www.rust-lang.org/) compiler. However, many libraries, such as OpenSSL, still require C/C++ compiler, as well, to build them. On Windows, the recommended compiler is the [Visual Studio C++ **Build** Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/). (Note: This application is _different/separate_ from [Visual Studio](https://visualstudio.microsoft.com/) and [Visual Studio Code](https://code.visualstudio.com/). It is the _free_ compiler suite for C/C++ applications that underpins Visual Studio.)
287
+
288
+
### Install OpenSSL library/SDK
289
+
Before installing the Visual Studio C++ Build Tools, you will need to install the OpenSSL library/SDK. Install from the [official repository](https://slproweb.com/products/Win32OpenSSL.html), making sure to choose full package (_not_ the "light" version) for the appropriate architecture (Win32 or Win64).
290
+
291
+
Ensure that you choose the version of OpenSSL compatible with the version of `cryptography` package that you are installing. For example, the current (as of this writing) version of OpenSSL is 3.0.2, which works fine with current version of `cryptography` (37.x.x). However, if you are installing an earlier version of `cryptography`, you may need to use an earlier version of OpenSSL, such as 1.1.1n. As an example, I found that I had to use OpenSSL **1.1.1n** to compile `cryptography` version **[3.4.7](https://cryptography.io/en/3.4.7/)**.
292
+
293
+
In general, the default installation settings, including copying the libraries to the Windows directory, should work fine. Make note of the installation directory, as this information will be needed later when compiling the libraries for the `cryptography` package.
294
+
295
+
### Install Visual Studio C++ Build Tools
296
+
Download and run **as an Administrator** the installation wrapper for Visual Studio C++ Build Tools from the [Microsoft site](https://visualstudio.microsoft.com/visual-cpp-build-tools/). This tool will, in turn, install the Visual Studio installation tool and launch it with the "Build Tools" default selection, which is also called _**Desktop development with C++**__workload_. The right pane of the window (**Installation details**) will list the actual components for installation; ensure that you install _at least_ the following items:
297
+
- **Included**
298
+
- C++ Build Tools core features
299
+
- C++ 2019 Redistributable Update
300
+
- C++ core desktop features
301
+
- **Optional**
302
+
- MSVC v142 - VS 2019 C++ x64/x86 build tools
303
+
- Windows 10 SDK (10.0.19041.0)
304
+
- C++ CMake tools for Windows
305
+
- Testing tools core features - Build Tools
306
+
- C++ AddressSanitizer
307
+
The **Included** tools list is fixed and you won't be able to change it. In addition, some of the items in the **Optional** tools list may have different version numbers; just look the item with the closest name and highest version number. The total installation size is likely to be approximately **6.5 GB**. Continue with the installation after confirming the **Installation details**.
308
+
309
+
### Install Rust compiler and build tools
310
+
The [Rust](https://www.rust-lang.org/) installation is quite straightforward. Download the `rustup` launcher (`rustup-init.exe`) from from the Rust web site. Open an **Administrator** Windows Command Prompt and run `rustup-init.exe` from it. Follow the default prompts, which will configure Rust in your "home" directory. Close the Windows Command Prompt after successful installation, so that environment changes are active in the next step.
311
+
312
+
### Install the `cryptography` package
313
+
Open a Windows Command Prompt. (This Command Prompt does _NOT_ require Administrator privileges.) Configure the Command Prompt environment for running the Visual Studio C++ Build Tools C++ compiler by running the `vcvarsall.bat` script; if you used the default directory for installation, it will be in `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build` directory. Typically, the command will be:
Failure to set the environment configuration via `vcvarsall.bat` script will typically result in an error similar to:
318
+
```bash
319
+
pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
320
+
```
321
+
(If you are missing the `vcvarsall.bat` script, then you probably did not install the Windows 10 SDK optional component when installing Visual Studio C++ Build Tools.)
322
+
323
+
We also need to set the `INCLUDE` and `LIB` environment variables to reference the appropriate directories for OpenSSL, per the [`cryptography` install documentation](https://cryptography.io/en/latest/installation/#building-cryptography-on-windows). Assuming that you installed OpenSSL to the default directory (`C:\Program Files\OpenSSL-win64`), the commands will be:
Now, we are _almost_ ready to install `cryptography` package! Ensure that you are in the desired virtual environment (unless you intend to install globally and have your future virtual environments inherit this configuration); for example, you might run `.venv/Scripts/activate.bat` from within your project directory. After activating the virtual environment, install `cryptography` package using `pip` as usual:
330
+
```bash
331
+
C:\> python -m pip install cryptography
332
+
```
333
+
During the installation, you'll see the usual process of downloading the various wheel packages. Likewise, `pip` will download the required source files for the binary packages and compile and install them. Ultimately, the installation should complete with message similar to:
334
+
```bash
335
+
Installing collected packages: cryptography
336
+
Running setup.py install for cryptography ... done
0 commit comments