tutorials1 Min Read

How to Install packages from command line and Dockerfile with Chocolatey

Gorav Singal

March 03, 2021

TL;DR

Use Chocolatey package manager on Windows to install tools like Git and osquery from the command line or within a Dockerfile.

How to Install packages from command line and Dockerfile with Chocolatey

Introduction

We will introduce a Package Manager for Windows: Chocolatey. In automations, it is necessary to install various tools, softwares from command line.

In this post, we will install git and osquery.

Install Chocolatey

Open powershell console.

RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
 iex ((New-Object System.Net.WebClient).DownloadString("https://chocolatey.org/install.ps1"));

Install a package (git)

Lets install git.

choco install git -y

Install specific version of a package

choco install osquery --version 3.4.0 -y;

Dockerfile

FROM microsoft/windowsservercore:ltsc2016

ENV CHOCO_URL=https://chocolatey.org/install.ps1
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
 iex ((New-Object System.Net.WebClient).DownloadString("$env:CHOCO_URL"));

RUN choco install git -y;
RUN choco install osquery --version 3.4.0 -y;
Share

Related Posts

How to Copy Local Docker Image to Another Host Without Repository and Load

How to Copy Local Docker Image to Another Host Without Repository and Load

Introduction Consider a scenario where you are building a docker image on your…

How to install Perl from Command Line for Automation on Windows and Dockerfile

How to install Perl from Command Line for Automation on Windows and Dockerfile

Introduction Often in automation, we need to install stuff from command line…

Explore useful Automation Techniques with Powershell on Windows

Explore useful Automation Techniques with Powershell on Windows

Introduction We will list few interesting automation techniques with powershell…

How to connect to a running mysql service on host from a docker container on same host

How to connect to a running mysql service on host from a docker container on same host

Introduction I have a host running mysql (not on a container). I have to run an…

Docker: unauthorized: incorrect username or password.

Docker: unauthorized: incorrect username or password.

While running docker commands with some images, I started getting error: The…

Docker image for Drupal 7, and Php extension MongoDB installed.

Docker image for Drupal 7, and Php extension MongoDB installed.

You have drupal 7 image from docker hub, and want to connect tomongo db via php…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…