Switching Docker Desktop to Docker CLI in Easy Way

Hello everyone! In this blog, we'll explore an important aspect of Docker development with Sitecore. Most of us are familiar with using Docker Desktop for our development needs—it's user-friendly and offers a great interface for managing your Docker environment. However, the downside is that it's a licensed product.

Let’s explore how Docker CLI can help us eliminate the licensing costs associated with Docker Desktop. We'll also look at how smoothly we can transition from using Docker Desktop to Docker CLI

Step 1: Uninstall Docker Desktop

Step 2: Install Docker Engine and CLI

Uninstall Docker Desktop

  • Make sure containers are stopped using following cmdlets:
           
    # Leave swarm mode (this will automatically stop and remove services and overlay networks)
    docker swarm leave --force
     
    # Stops all containers
    docker ps --quiet | ForEach-Object {docker stop $_}
    	   
    
  • If you want to remove all containers, container images, networks, and volumes from your system, then run the following cmdlet
           
           docker system prune --volumes --all --force
    	   
    
  • Uninstall docker
           
    # For windows 10 
    Navigate to Control Panel --> Apps and Feature --> Docker Desktop -->Uninstall       
           
    #For Windows Server : Run elevated session with following cmdlets:
    Uninstall-Package -Name docker -ProviderName DockerMsftProvider
    Uninstall-Module -Name DockerMsftProvider
    	   
    
  • Remove docker network
           
    # For windows 10       
    Run elevated session with following PS cmdlets:
    Get-HNSNetwork | Remove-HNSNetwork
    
    #For windows Server
    Run elevated session with following PS cmdlets:
    Get-ContainerNetwork | Remove-ContainerNetwork
    	   
    
  • Clean docker default directory
           
    # Take ownership of all files under the docker root folder
    takeown.exe /F "C:\ProgramData\Docker" /R /A /D Y
     
    # Assign full permissions to the Administrators role
    icacls "C:\ProgramData\Docker\" /T /C /grant Administrators:F
     
    # Remove the root folder
    Remove-Item "C:\ProgramData\Docker" -Recurse -Force
    	   
    
  • Make changes in the docker configuration file for your user profile
    • Open the file %userprofile%\.docker\config.json
    • Delete the line "credsStore": "desktop" if it exists
    • Save the file
  • Delete the daemon config file C:\ProgramData\docker\config\daemon.json
           
    Remove-Item C:\ProgramData\docker\config\daemon.json -Force
    	   
    

At this point your docker desktop is uninstalled properly.

Install Docker Engine and CLI

  • Install Chocolatey - universal package manager for Windows
  • Using choco, install necessary docker tools and configure Hyper-V
           
    # Install the Docker Engine, Docker CLI and the Docker Compose CLI Add-on (installs the CLI as a dependency)
    choco install docker-engine docker-compose
     
    # Enable the Containers and Hyper-V Windows features
    choco install Containers Microsoft-Hyper-V --source windowsfeatures
    	   
    
  • Run following PS cmdlet in an elevated session, to apply the DNS configuration changes in C:\ProgramData\docker\config\daemon.json
           
    $dockerSettings = @{"dns" = @("10.253.0.10","8.8.8.8") ; "experimental" = $false ; "group" = "docker-users"}
    $dockerSettingsJson = $dockerSettings | ConvertTo-Json
    $dockerDesktopSettingsPath = "C:\ProgramData\docker\config\daemon.json"
    Set-Content -Path $dockerDesktopSettingsPath -Value $dockerSettingsJson
    	   
    
  • Start the Docker Engine service by running following cmdlet
  •        
    Start-Service -Name "docker"
    	   
    

Now you are good to go with Docker CLI. Thanks for reading!!. Want to learn docker commands, then find the link here

You can check my other blogs too if interested. Blog Website

Comments

Popular posts from this blog

Automate RSS Feed to Sitecore XM Cloud: Logic App, Next.js API & Authoring API Integration

Create and Fetch Content From Sitecore Content Hub One using GraphQL and React

Sitecore XM Cloud Form Integration with Azure Function as Webhook