Change the location folder of Docker image & container

Purpose

I want to bring the docker image and vhdx where the container is saved to any folder on the D drive instead of C. Basically, I followed the procedure linked to as a reference.

I tried it but it doesn't work

chgdockerdir_failed.ps


wsl --import docker-desktop D:\Docker\docker-desktop docker-desktop.tar

After running the above, the import destination is not vhdx, A group of folders with a directory structure like Linux is created. Even in that state, Docker Desktop will start, and docker -v will return the version information. The docker run command does not start and the following error occurs.

chgdockerdir_failed2.ps


docker run -d -p 80:80 docker/getting-started
docker: Error response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file specified.

Cause?

chgdockerdir_failed2.ps


wsl --import docker-desktop D:\Docker\docker-desktop docker-desktop.tar --version 2

With this, I was able to import with vhdx successfully. If not specified, may it be version1? There seems to be a command that can set wsl defaults, so Isn't there any problem if it is set in advance?

wsl --set-default-version 2 It seems that it is OK even if you do not specify the version at the time of import if you set it in advance with.

By the way, if neither one nor the other goes Docker Desktop Troubleshooting Press "Clean / Purge data" to restore.

The final command

Implemented from Powershell below

chgdockerdir.ps


#Stop docker
#Set the default wsl version to 2
wsl --set-default-version 2
#Shut down the distribution once
wsl --shutdown
wsl -l -v
#  NAME                   STATE           VERSION
#* docker-desktop         Stopped         2
#  docker-desktop-data    Stopped         2

#Export the current vhxd in tar format
wsl --export docker-desktop docker-desktop.tar
wsl --export docker-desktop-data docker-desktop-data.tar

wsl --unregister docker-desktop
#Unregistered...
wsl --unregister docker-desktop-data
#Unregistered...

#Load the tar you just exported
wsl --import docker-desktop D:\Docker\docker-desktop docker-desktop.tar
wsl --import docker-desktop-data D:\Docker\docker-desktop-data docker-desktop-data.tar

reference

I want to change the storage location of the WSL2 Docker image container (I want to move the WSL2 vhdx file) How to move Docker Desktop disk space from C drive to another drive Importing and exporting "WSL" distributions is so easy!

Recommended Posts

Change the location folder of Docker image & container
The story of updating SonarQube's Docker Container
Change the timezone of the https-portal container to JST
Docker monitoring-explaining the basics of basics-
Understand the basics of docker
Nginx container that displays the Hostname of the host running Docker
Let's grasp the operation image (atmosphere) of the DI container of Spring
Get only the ID of the container specified by docker ps
[Swift] Change the textColor of UIDatePicker
I created a Docker image of a container for learning OpenAI Gym
[GCP] Until you push the local Docker image to the Container Registry
Display text on top of the image
Introducing the features of JavaFX SceneBuilder container
Bootstrap4 Change the color of the hamburger menu
[Rails] Change the label name of f.label
[Docker] Start the container as soon as possible
[Docker] Start container, start bash in container, delete image
[Swift] Change the color of SCN Node
Japanese setting of mysql in Docker container
[Error] Error during Docker build (solved by pulling the latest version of image)
Change the save destination of the image to S3 in the Rails app. Part 2
How to mount the batch file location via WSL2 and start the Docker container
How to display the amount of disk used by Docker container for each container
Up to the point of launching a Docker container built using RedHat Quarkus
A quick note on using jshell with the official Docker image of the JDK
How to check the logs in the Docker container
[Docker] Check the running container and enter there
Measure the size of a folder in Java
Improve the performance of your Docker development environment
Change the URL of the application of Eclipse project (Maven).
Update container image with KUSANAGI Runs on Docker
[Java / Kotlin] Resize considering the orientation of the image
How Microservices Change the Way of Developing Applications
[AndroidStudio] Change the color of the ActionBarDrawerToggle hamburger menu
How Docker works ~ Implement the container in 60 lines
Push the image to docker hub using Jib
[Java] How to get the authority of the folder
[Docker] How to see the contents of Volumes. Start a container with root privileges.
Small Docker container
Steps to push Docker image to GitHub Container Registry (ghcr.io)
I tried to summarize the state transition of docker
Docker the development environment of Ruby on Rails project
Weight reduction of Docker image by multi-stage build-React application
<Android> Change the background color of the List row of ListView
Image processing: The basic structure of the image read by the program
[Rails] How to change the column name of the table
Run the Android emulator on Docker using Android Emulator Container Scripts
[Rails] Cancel / change the default password validation of devise
Mandels to create an image of the Mandelbrot set
JavaFX-Specify the location of the CSS file relative to the fxml file
Verification of the relationship between Docker images and containers
Change the storage quality of JPEG images in Java
How to judge the click of any area of the image
SSL in the local environment of Docker / Rails / puma
Check the rate limit application status of docker pull
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
When rewriting the CMD of docker image of Pod in the manifest of k8s, command is not good