16 KiB
Docker Desktop
Docker Desktop is a powerful tool that simplifies the development, deployment, and management of applications using containers. Here's an introduction to Docker Desktop:
What is Docker Desktop?
Docker Desktop is an application for both Mac and Windows operating systems that enables developers to create, deploy, and manage applications using Docker containers. It provides an easy-to-use interface for working with Docker containers, images, volumes, and networks.
Key Features
- Containerization: Docker Desktop utilizes containerization technology to package applications and their dependencies into lightweight, portable containers. This allows developers to isolate applications from their environment and ensures consistent behavior across different computing environments.
- Graphical User Interface (GUI): Docker Desktop comes with a user-friendly GUI that allows developers to perform container-related tasks such as creating, managing, and monitoring containers using a visual interface. This makes it easy for developers to interact with Docker without needing to use the command line.
- Integrated Development Environment (IDE) Integration: Docker Desktop seamlessly integrates with popular IDEs such as Visual Studio Code, allowing developers to build, debug, and test containerized applications directly from their development environment.
- Multi-Platform Support: Docker Desktop supports both Mac and Windows operating systems, allowing developers to build and run containerized applications on their preferred platform without needing to worry about compatibility issues.
- Local Development Environment: Docker Desktop provides a local development environment that closely mirrors production environments, allowing developers to build and test applications in an environment that closely resembles where they will eventually be deployed.
- Automatic Updates: Docker Desktop regularly receives updates and new features, ensuring that developers have access to the latest Docker capabilities and improvements.
Docker Desktop Architecture
Docker Desktop is a comprehensive package offered by Docker, providing both a graphical user interface (GUI) and a command-line interface (CLI). It serves as a unified platform for developers to manage their Docker containers and workflows seamlessly. One of its key features is its inclusion of a Linux virtual machine, which acts as the runtime environment for Docker containers on non-Linux systems such as Windows and macOS.
Note
For Windows, it is reuqired that the user install Windows Subsystem for Linux (WSL) seperately from the installation of Docker Desktop.
This virtual machine wraps around Docker's core components, including the CLI and the Docker API at the server side, facilitating the creation, management, and deployment of containers. Additionally, Docker Desktop includes the Docker Daemon, which is responsible for managing container lifecycle and interacting with the operating system's kernel.
While in a Linux environment, working directly with the Docker Engine, a lighter version of Docker, is often sufficient. However, for Windows users, especially those on Windows 11, Docker Desktop is recommended. This recommendation is primarily due to compatibility reasons, especially for users requiring NVIDIA GPU support for containerized applications.
In summary, Docker Desktop provides a unified solution for Docker container management, combining a user-friendly interface with essential tools and runtime environments to streamline the development and deployment of containerized applications across different operating systems.
Difference between images and containers
Container
- Execution Instance: A container is a runtime instance of an image. It's a lightweight, standalone, and executable package that encapsulates all the dependencies required to run a piece of software.
- Isolation: Containers provide process isolation, ensuring that applications running within them are isolated from one another and from the host system.
- Dynamic: Containers can be started, stopped, moved, and deleted dynamically. They are ephemeral by nature, meaning they can be created, destroyed, and replaced rapidly.
- Runtime Environment: Each container runs in its own isolated environment, including its own filesystem, networking, and process space.
Image
- Blueprint: An image is a static, immutable blueprint used to create containers. It's a snapshot of a container that includes the application code, runtime, libraries, dependencies, and other configuration needed to run the software.
- Build Artifact: Images are created either manually or through automated build processes. They are stored in a registry and serve as the foundation for creating containers.
- Reusable: Images can be shared, reused, and distributed across different environments and systems. They provide a consistent environment for running applications regardless of the underlying infrastructure.
- Layered Structure: Docker images are composed of multiple layers, with each layer representing a filesystem change. This layered structure enables efficient storage, distribution, and reuse of images.
Key Differences
- Statefulness: Containers are dynamic and stateful, while images are static and stateless. Containers can be modified and retain changes during runtime, whereas images remain immutable.
- Lifecycle: Containers have a lifecycle—they can be created, started, stopped, paused, and deleted. Images, on the other hand, do not have a lifecycle; they are static artifacts used to create containers.
- Composition: Images serve as the building blocks for containers. Multiple containers can be instantiated from the same image, each running independently with its own isolated environment.
- Persistence: Containers are ephemeral, meaning any changes made inside a container only persist as long as the container is running. Images, being immutable, preserve the state of the filesystem at the time of creation.
In essence, containers are the runtime instances of images, while images are the blueprints used to create containers. They work together to enable the efficient deployment, management, and execution of applications in a containerized environment.
Installation in Windows
Generally, enabling virtualization from the BIOS and installing Windows Subsystem for Linux (WSL) are crucial steps for setting up Docker Desktop on Windows machines. Here's an updated summary of the general steps for Windows installation, including these prerequisites and the links you provided:
- Enable Virtualization from BIOS: Before installing Docker Desktop, ensure that virtualization is enabled in your system's BIOS settings. This step is crucial for Docker Desktop to function properly on Windows machines. Refer to this link for instructions on how to enable virtualization: [Hardware-Assisted Virtualization and Data Execution Protection](https://forums.docker.com/t/hardware-assisted-virtualization-and-data-execution-protection-must-be-enabled-in-the-bios/109073).
- Install Windows Subsystem for Linux (WSL): Docker Desktop relies on WSL to run Linux containers on Windows. Install WSL by following the instructions provided in this link: [Install Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/install).
- Download Docker Desktop Installer: Visit the official Docker website and navigate to the Windows installation page. From there, download the Docker Desktop installer executable.
- Run the Installer: After downloading the installer, double-click on it to launch the installation wizard.
- Follow Installation Instructions: Follow the on-screen instructions provided by the installation wizard. This includes accepting the license agreement, choosing installation options, and specifying the installation location.
- System Requirements Check: During the installation process, Docker Desktop may perform a system requirements check to ensure your system meets the necessary prerequisites for installation.
- Enable Hyper-V (if required): Docker Desktop for Windows may require Hyper-V to be enabled. (It can also work with WSL) If it's not already enabled, the installer will prompt you to enable it. This step might require a system reboot.
- Configuration: Once the installation is complete, Docker Desktop may require additional configuration, such as configuring shared drives or network settings.
- Launch Docker Desktop: After successful installation and configuration, Docker Desktop can be launched from the Start menu or desktop shortcut.
- Sign in (if required): Depending on your Docker configuration, you may need to sign in to your Docker account during the initial setup. Sign-in is usually optional.
- Verify Installation: To ensure Docker Desktop is installed correctly, you can open a command prompt or PowerShell window and run docker --version to verify the Docker CLI version.
- Start Using Docker: With Docker Desktop installed and running, you're ready to start building, running, and managing containers on your Windows system. To use Docker CLI, users will have to start Docker Desktop.
By following these steps, including enabling virtualization from the BIOS and installing WSL, you can successfully install Docker Desktop on your Windows machine and leverage the benefits of containerization for your development projects.
Enable Virtualization for Windows Machine
Accessing the BIOS (Basic Input/Output System) varies slightly depending on your computer's manufacturer and model. Here's a general guide on how to access the BIOS on most Windows computers:
- Shut Down Your Computer: Ensure that your computer is fully powered off, not just in sleep or hibernate mode.
- Start Your Computer: Press the power button to turn on your computer.
- Start Tapping the BIOS Key: Immediately after pressing the power button, start tapping the appropriate key to enter the BIOS. The BIOS key varies depending on your computer's manufacturer. Common keys include:
- F2
- F10
- F12
- Esc
- Delete
- Enter
- Check for BIOS Key: If you're unsure which key to press, check your computer's manual or the manufacturer's website. Sometimes, the BIOS key is displayed briefly on the screen during startup.
- Enter BIOS Setup: Continuously tapping the BIOS key should bring you to the BIOS setup screen. This screen typically has a blue or black background with various options and settings.
- Navigate BIOS Menu: Once inside the BIOS setup, you can navigate using the arrow keys on your keyboard. Be cautious when making changes in the BIOS, as incorrect settings can affect the stability and performance of your computer.
- Enable Virtualization: Look for settings related to virtualization (e.g., Intel Virtualization Technology, AMD-V) in the BIOS setup. Depending on your BIOS version and layout, virtualization settings may be located under different menus such as "Advanced," "Security," or "CPU Configuration." Enable virtualization if it's disabled.
- Save and Exit: After making changes, save your settings and exit the BIOS setup. This process is usually done by pressing the appropriate key (often labeled as "Save & Exit" or similar) and confirming your choice.
- Restart Your Computer: Once you've exited the BIOS setup, your computer will restart.
- Verify Virtualization: After restarting, you can verify if virtualization is enabled by checking your computer's system information or BIOS settings.
Remember, accessing the BIOS can vary depending on your computer's manufacturer and model, so if you're unsure, refer to your computer's manual or the manufacturer's website for specific instructions.
Installing WSL
To install Windows Subsystem for Linux (WSL) and manage its settings, follow these steps:
- Install WSL: Open PowerShell or Windows Command Prompt as an administrator and run the command ''wsl --install''. This command enables the necessary features to run WSL and installs the default Ubuntu distribution of Linux. After running the command, restart your machine.
- Check WSL Version: To check which version of WSL you are running and view your installed Linux distributions, use the command ''wsl -l -v'' in PowerShell or Command Prompt.
- Set Default WSL Version: If you want to set the default version to WSL 1 or WSL 2, use the command ''wsl --set-default-version <Version#>'', replacing <Version#> with either 1 or 2.
- Set Default Linux Distribution: To set the default Linux distribution used with the ''wsl'' command, enter ''wsl -s <DistributionName>'' or ''wsl --set-default <DistributionName>'', replacing ''<DistributionName>'' with the name of the Linux distribution you want to use.
Following these steps allows you to easily install and manage Windows Subsystem for Linux (WSL) on your Windows machine, enabling you to run Linux commands and utilities alongside your Windows environment.
Installation in Linux
In general, Docker Engine can be installed on Ubuntu Linux using the instructions provided in the official Docker documentation at https://docs.docker.com/engine/install/ubuntu/. This documentation outlines the steps necessary to install Docker Engine on an Ubuntu system, ensuring that you have the latest version of Docker available for your use.
- Set up Docker's apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
- To install the latest version, run:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world
Supported Operating Systems
Docker Desktop is available for installation on the following operating systems:
- Windows 10/11: Docker Desktop is compatible with Windows 10 and Windows 11 operating systems. It leverages the native Hyper-V virtualization technology on Windows to run containers.
Warning
To ensure NVIDIA GPU compatibility, please use the latest updated Windows 10 or Windows 11. When we tested it with Windows 10 on our machine (not with the latest patches), the code ran into memory errors. However, after updating to Windows 11, the software ran without issues.
More information can be found in the following links:
- Mac: Docker Desktop is compatible with macOS, allowing Mac users to build and manage containers seamlessly using the Docker Desktop application.
- Linux (Ubuntu Distro 22 and above): Docker Desktop is supported on Linux systems running Ubuntu distributions version 22 and above. It provides a convenient way for Linux users to utilize Docker containers within their development workflow.
Note
For Linux Ubuntu Distro 20, we can only install Docker Engine, which is sufficient for most cases.