跳至主要內容

Install Docker-Desktop and Docker-Data to other drive on Windows 11

If you have read my post (https://blog.takurohuang.com/2023/07/03/install-wsl2-to-other-disk-drive-and-intro-basic-commands-for-wsl/), the subsequent step would likely involve installing Docker on your desktop. However, you may encounter a similar challenge in installing Docker on a drive other than the default C: drive.

If so, this post will be an answer for you.

Install Docker Desktop:

  1. Download Docker desktop from Docker official site (https://www.docker.com/products/docker-desktop/).
  2. To install Docker Desktop using the command line and specify a custom installation directory, you can follow these refined steps:
    • Open a terminal or command prompt.
    • Navigate to the directory where the “Docker Desktop Installer.exe” file is located using the cd command. For example cd C:\Path\To\Installer\Folder
    • Execute the following command to start the Docker Desktop installation with the specified installation directorystart /w "" "Docker Desktop Installer.exe" install --accept-license --installation-dir=D:\Docker\ Replace D:\Docker\ with the desired installation directory path on your system.
  3. Execute Docker Desktop application to see if everything works.
  4. Open another terminal or command prompt and enter wsl -l -v. You should see like this:
    docker-desktop is the application, docker-desktop-data is where the images will be stored. If you followed the instruction correctly, then docker-desktop should be installed at where you have indicated.

Move docker-desktop-data to other drive

Despite choosing a different installation directory, the docker-desktop-data folder, which contains Docker’s data including images, containers, and other persistent information, will still be located on the system drive (typically C: drive) by default. This can result in rapid growth of the folder, particularly when working with multiple images. Therefore, next step is moving docker-desktop-data to other drive.

  1. Open a terminal and enter wsl --shutdown to stop all subsystems.
  2. Export docker-desktop-data to somewhere by entering wsl --export docker-desktop-data D:\Docker-Data\docker-desktop-data.tar. You can change D:\Docker-Data\docker-desktop-data.tar accordingly. Just make sure that the path is existing in your machine.
  3. Unregister docker-desktop-data by entering wsl --unregister docker-desktop-data. This command will also delete the original ext4.vhdx in defaut drive (typically C: drive)
  4. Import docker-desktop-data again and assign a path to indicate where it should be store. You can do it via wsl --import docker-desktop-data D:\Docker\data D:\Docker-Data\docker-desktop-data.tar --version 2. Replace D:\Docker\data with the appropriate path where you want to store the “docker-desktop-data” folder. Additionally, ensure that the path D:\Docker-Data\docker-desktop-data.tar matches the location where you have stored the exported file from step 2.
  5. Enter wsl -v -l to see if you can still see docker-desktop-data and docker-desktop.
分類:Hands-on

搶先發佈留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

由 Compete Themes 設計的 Author 佈景主題