Blog Post

Containers
3 MIN READ

Tar and Curl Come to Windows!

Virtualization-Team's avatar
Virtualization-Team
Brass Contributor
Mar 22, 2019
First published on TECHNET on Dec 19, 2017
Beginning in Insider Build 17063, we’re introducing two command-line tools to the Windows toolchain: curl and bsdtar. It’s been a long time coming, I know. We'd like to give credit to the folks who’ve created and maintain http://libarchive.org/ and https://curl.haxx.se/ —awesome open-source tools used by millions of humans every day. Let's take a look at two impactful ways these tools will make developing on Windows an even better experience.

1. Developers! Developers! Developers!


Tar and curl are staples in a developer’s toolbox; beginning today, you’ll find these tools are available from the command-line for all SKUs of Windows. And yes, they're the same tools you've come to know and love! If you're unfamiliar with these tools, here's an overview of what they do:

  • Tar: A command line tool that allows a user to extract files and create archives. Outside of PowerShell or the installation of third party software, there was no way to extract a file from cmd.exe. We're correcting this behavior :) The implementation we're shipping in Windows uses http://libarchive.org/ .

  • Curl: Another command line tool that allows for transferring of files to and from servers (so you can, say, now download a file from the internet).


Now not only will you be able to perform file transfers from the command line,  you'll also be able to extract files in formats in addition to .zip (like .tar.gz, for example). PowerShell does already offer similar functionality (it has curl and it's own file extraction utilities), but we recognize that there might be instances where PowerShell is not readily available or the user wants to stay in cmd.


2. The Containers Experience


Now that we’re shipping these tools inbox, you no longer need to worry about using a separate container image as the builder when targeting nanoserver-based containers. Instead, we can invoke the tools like so:


Background


We offer two base images for our containers: windowsservercore and nanoserver . The servercore image is the larger of the two and has support for such things as the full .NET framework. On the opposite end of the spectrum is nanoserver, which is built to be lightweight with as minimal a memory footprint   as possible. It’s capable of running .NET core but, in keeping with the minimalism, we’ve tried to slim down the image size as much as possible. We threw out all components we felt were not mission-critical for the container image.

PowerShell was one of the components that was put on the chopping block for our nanoserver image. PowerShell is a whopping 56 Mb (given that the total size of the nanoserver image is 200 Mb…that’s quite the savings!) But the consequence of removing PowerShell meant there was no way to pull down a package and unzip it from within the container.



If you’re familiar with writing dockerfiles, you’ll know that it’s common practice to pull in all the packages (node, mongo, etc.) you need and install them. Instead, users would have to rely on using a separate image with PowerShell as the “builder” image to accomplish constructing an image. This is clearly not the experience we want our users to have when targeting nanoserver—they’d end up having to download the much larger servercore image.

This is all resolved with the addition of curl and tar. You can call these tools from servercore images as well.




We want your Feedback!


Are there other developer tools you would like to see added to the command-line? Drop a comment below with your thoughts! In the mean time, go grab Insider Build 17063 and get busy curl’ing an tar’ing to your heart’s desire.
Published Mar 22, 2019
Version 1.0

18 Comments

  • enwinn's avatar
    enwinn
    Copper Contributor

    As of Aug 21, 2020, my Windows 10 v1809 is showing the curl.exe in System32 and SysWOW64 as version 7.55.1 but the current version is 7.72.0 where many of the updates since v7.55.1 have been fixes for security vulnerabilities.

     

    What gives Microsoft? As another commenter pointed out, if you are going to include it then WSUS and/or Microsoft Updates _needs_ to keep it current.

     

    I'll also point out that you've made it difficult to update or remove the Microsoft provided curl manually since ICALCS shows the owner with FULL permissions to be NT SERVICE\TrustedInstaller with every other defined user as only having Read, Execute.

     

    Installing Git for Windows also includes curl but at least those folks are pretty good about keeping curl current. Unfortunately many people will have a path configuration that will use your obsolete, built-in instance.

     

    Not cool, Microsoft! Not cool at all.

  • AluminumFalcon's avatar
    AluminumFalcon
    Copper Contributor

    No for Server 2016, but it does work on Windows Server 2019, [Version 10.0.17763.1339] at the time of this writing.

  • BhawtoshJani's avatar
    BhawtoshJani
    Copper Contributor

    Can anyone tell or update this article - Is this applicable to windows server 2016 and 2019 as well ?

  • Good to know that it is coming in built with Win 10. Will it still be there in the upcoming OS of Windows? For one of our projects we are planning to use Curl on client side for transferring files to FTPS server and if that does not come in built in future windows OS, we may need to explore for some other options. 

  • npocmaka_'s avatar
    npocmaka_
    Copper Contributor

    Some time ago I've tried to create scripts that can archive files and do http requests:

    https://stackoverflow.com/questions/28143160/how-can-i-download-a-file-with-batch-file-without-using-any-external-tools

    and 

    https://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-bat

     

    I don't know if a simple , text only script is a third party software but may be in some cases these are worth checking.

  • DACBARBOS's avatar
    DACBARBOS
    Copper Contributor

    New year, https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/#comments. I don't get it MSFT. Why bother including curl if no intent on maintaining it https://curl.haxx.se/windows.

  • Justin King's avatar
    Justin King
    Brass Contributor

    This is awesome ... but part of me wishes you would pull cmd out rather than powershell out of the nano containers.  I feel like we are stuck between two admin worlds... we keep talking about using PowerShell for CM ... but keep comming back to cmd.  

    That said ... curl especially is most welcome.  Certainly going to streamline things.  Even if it does mean cmd lives for another decade.