11/23/2021»»Tuesday

Install Docker With Chocolatey

The Docker tools are useful on a Windows machine to build and run applications in Linux containers locally in a VM or in the cloud. With the Chocolatey package manager you can install all the Docker tools you need to get started.

If you don't know what a shell window is then you should have a look at the Docker Toolbox from Docker. But if you know and use a PowerShell or CMD shell window from time to time I'll guide you through the simple steps.

To download and install Docker CLI with chocolatey write the following command in the terminal window. Choco install docker-cli -y. This command will go ahead and download Docker CLI with your permission and install it. Let me take a couple of minutes depending on the internet speed. Was it installed let’s go ahead and check if Docker help. Otherwise install the latest Docker Desktop for Windows and select the WSL2-based engine (not legacy Hyper-V) when installing. Install via Chocolatey with choco install docker-desktop or it can be downloaded from desktop.docker.com. It may prompt you to log out and log in again, or reboot. To install the Docker-Microsoft PackageManagement Provider from the PowerShell Gallery. Run the following PowerShell commands as administrator. Once the installation of DockerMsftProvider is complete, Use the Install-Package cmdlet with the following syntax to install Docker. Important: The provider enables the containers feature on your Server. The init.ps1 will install SitecoreDockerTools and populate your.env file with the appropriate values. It also adds the hosts entries and SSL certificates. Now, run docker-compose pull. This will pull all the images specified in the docker-compose.yml file. Run docker-compose up -d (or docker-compose up —detach). This builds, (re)creates.

Let's get Chocolatey

Chocolatey is an open source project to provide a package manager for Windows as you might know it from Linux distro. You can install many of your software on your Windows machine with it.

Just open chocolatey.org and search for eg. Chrome, Adobe Reader, or other tools you have installed manually in the past. You will find out fast that nearly everything could be installed with just the command

That makes Chocolatey really cool. It's like apt-get, but for Windows. And the software is downloaded from the original places, the choco packages only contains the instructions where to download it and how to install it silent.

If you haven't installed Chocolatey already just open the homepage https://chocolatey.org and copy the simple command to your shell.

Docker Chocolatey packages

To see which Docker tools are available through Chocolatey packages, just open the Chocolatey homepage and search for docker.

The Chocolatey packages for the Docker tools are maintained by the community. But they are kept up-to-date, so you can update each tool soon after the official release.

At the moment you can install

  • Docker Client
  • Docker Machine
  • Docker Compose

as well as a Docker Machine driver plugin for VMware Workstation.

Docker Client

To begin with Docker you need the Docker Client. Install it in a PowerShell or CMD shell window with

The option -y just auto-answers the question to run the install script.

Now we have the docker command installed. Try it out with docker --version for the installed version or docker --help to see the usage. This client will be used to build and run Docker Containers.

Docker Machine

The next step is to create a VM to run the Linux containers in it. Docker Machine is the right tool for that task. So we first install it with

With

Local Hypervisor

Windows users can select between these three local hypervisors to run a Linux Docker Engine in it.

  • Hyper-V
  • VirtualBox
  • VMware Workstation

All three hypervisors can be controlled by Docker Machine.

For Hyper-V follow the official guide how to install it on your machine.

VirtualBox can also be installed with Chocolatey, guess how

For VMware Workstation you also need the driver plugin and VMware Workstation if not already installed:

For VMware Workstation you enter your license before using it.

Cloud

You also can create a VM in the cloud, Docker Machine has a lot of cloud drivers built in.

  • Windows Azure
  • Digital Ocean
  • Google GCE
  • OpenStack
  • Rackspace
  • ...

See the official guide Using Docker Machine with a cloud provider for more details.

Create a Docker Machine

After you have set up your local hypervisor or chosen the cloud provider you want to use, create a Docker Machine VM with the name dev with one of these commands:

There are driver specific options to tweak the VM settings or the token to connect to your account in the cloud.

After a while you will have your local or remote Docker Machine up and running.

You can check the status of the machine(s) with

Connect to your Docker Machine

For the Docker Client you need some environment variables so that the Docker Client knows how to connect to your local or remote Docker Engine.

In PowerShell it is really easy to set these environments.

With

In the near future can skip the --shell parameter as well to simplify this step.

After that you can control the Docker engine and start your first container, eg. this interactive shell

Type exit to terminate the container.
Congratulations! You have started your first container.

Docker Compose

Install Docker With Chocolatey Mouse

If you want to start more than one container that should work together you can use Docker Compose. It simplifies this task to setup a multi container application.

Please refer to the official Overview of Docker Compose guide to find out more.

Now you are ready to work from your Windows machine and control the world of Linux containers. In the near future you also can do this with Windows containers as well.

TL/DR

With just a few commands you get all the Docker tools installed on your Windows machine. And it fits into a single tweet:

Get the latest @Docker tools for #Windows: choco install dockerchoco install docker-machinechoco install docker-compose Done!

— Stefan Scherer (@stefscherer) 6. November 2015

If you like this blog post please share it with a friend or leave a comment to give feedback or ask questions.

Learn the simple commands to use on Powershell for installing Docker on Windows 10 with WSL 2 support for creating an optimized and fast container environment to run various Virtual machine images.

Well, when it comes to installing Docker on Windows 10, most of us struggle with the problem of enabling Hyper-V because it won’t work properly without that. However, if we don’t want to use Hyper-V for Docker installation then using WSL 2 support would be a good idea.

WSL which is already available in the Windows 10 operating system and now comes with the ability to run full-fledged Linux kernel using WSL 2, makes it very easy to operate Docker without Hyper-V or VirtualBox.

Read More:Tutorial to install Docker on Windows 7 without Hyper-V.

Pre-requisites:

  • Windows 10 OS
  • Admin access
  • Powershell
  • WSL- Windows Subsystem for Linux
  • Internet connection

Install Docker using Powershell on Windows 10 with a single command

Most of us download and use the executable file available on the official website of this containerized platform to set it up, however, you don’t have to do all that. Just use the command line, follow the below steps, and you are done.

Note: Make sure the WSL- Windows subsystem for Linux is already enabled on your system before performing the below-given steps.

Open PowerShell as Admin

We need to have the Administrator access of PowerShell to run the installation command for Docker, thus, right-click on the Windows 10 Start button and select the “Windows PowerShell (Admin)” option.

Install Chocolatey

Just like Linux packages managers, for example, DNF of CentOS and APT available in Ubuntu, one is also available for Windows operating systems called Chocolatey. The command tool used by this Windows package manager is choco.

Run the below command to enable it in Powershell

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))

Note: Once the Chocolatey is on your system, close the Powershell and reopen it as Admin.

Command to install Docker Desktop using PowerShell on Windows

Now, everything is ready on Powershell and we can use the Choco command to install Docker on Windows 10 Desktop or Windows Server OS.

When the above command asks for your permission to install the packages, allow it by typing A and hitting the Enter key.

Run Docker Desktop

You will see the icon on your desktop to run this open source containerized platform, double click on that. And start it.

Configure WSL 2 Distro

Although after installing the Docker, it will automatically install its own WSL 2 Linux distro on your system as the default one. Thus, you can easily start using it from PowerShell. In case you want to enable the docker support to other available WSL Linux distros then simply go to the Docker Desktop app, select the Resources option given on the left side, and select WSL integration. You will find all installed and available WSL distros there, use the toggle button given in the front of the distro to enable the support. After that, the particular WSL Linux distro for which you have enabled its support can directly run all the Docker commands without actually installing on that distro.

Extra Tip: Convert WSL 1 distro to WSl 2

In case your WSL distro is still on WSl 1 then you have to first enable the WSL 2 support. For that run your Powershell as Admin and use this command:

Docker Install Chocolatey In Container

Now, go to the Microsoft page to download the WSL 2 kernel update setup, use this link to directly download and upgrade the kernel.

Once all this done, simply restart the system.

Now, open Powershell again as admin and type:

The above command will show all the installed WSL distro on your system. Find out the name of one which you want to convert. For example, we have Ubuntu-18.04 WSL distro and to convert it from WSL 1 to WSL 2, we will run the command:

Install Docker With Chocolatey Crack

wsl --set-version distro-name 2

Install Docker With Chocolatey Keyboard

So, as per the example, the command will be like this:

Install Docker Windows Chocolatey

I hope this article somehow helped you, if you have any query please feel free to comment.

Most Viewed Posts