Moving docker image's location to Drive D still occupying drive C's space - ubuntu-20.04

I tried moving Docker Desktop's image's location from System disk to Drive D to avoid over-consuming the system disk
By doing so: reference
1. Export docker-desktop-data into a file:
- wsl --export docker-desktop-data "D:\Docker\wsl\data\docker-desktop-data.tar"
2. Unregister docker-desktop-data from wsl:
- wsl --unregister docker-desktop-data
3. Import the docker-desktop-data back to wsl, but now the ext4.vhdx would reside in different drive/directory:
- wsl --import docker-desktop-data "D:\Docker\wsl\data" "D:\Docker\wsl\data\docker-desktop-data.tar" --version 2
Start the docker again, and also reboot to make sure everything works fine.
Now, in my wsl2 ubuntu distro, I tried importing sql dumps into the db container in docker.
I can see that both drive C and D 's space is getting reduced as the import goes on.
But mostly, drive C gets reduced more than drive D.
Note: I also moved the WSL2 instance in drive D, reference
Is this normal that drive C still gets consumed even after moving the docker's image location and WSL2 instance to Drive D?
If it isn't, can someone point out where I did wrong and how to resolve?
BTW, when I run wsl -d Ubuntu-20.04, I can see in terminal that it's prefixed with username#DESKTOP-######:/mnt/c/WINDOWS/system32, is this also normal even after moving the wsl2 instance to drive D?

Related

How to change the location of docker installation? [duplicate]

I've just upgraded to Windows 10 Home May 2020, activated WSL2, and installed Docker Desktop.
WSL2 must be installed in my system disk, which is a small SSD. I don't want to fill it with docker images. How do I change the docker images path? I'd like to use a path in my big Windows filesystem.
The image location is somewhat confusing. I believe it is in /mnt/wsl/docker-desktop-data/.
How do I change the directory of docker images inside WSL2? May I change docker configuration to select a path inside /mnt/d, or mount a path from /mnt/d over docker data dirs?
The WSL 2 docker-desktop-data vm disk image would normally reside in:
%USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx
Follow the following to relocate it to other drive/directory, with all existing docker data preserved (tested against Docker Desktop 2.3.0.4 (46911), and continued to work after updating the 3.1.0 (51484)):
First, shut down your docker desktop by right click on the Docker Desktop icon and select Quit Docker Desktop
Then, open your command prompt:
wsl --list -v
You should be able to see, make sure the STATE for both is Stopped.(wsl --shutdown)
NAME STATE VERSION
* docker-desktop Stopped 2
docker-desktop-data Stopped 2
Export docker-desktop-data into a file
wsl --export docker-desktop-data "D:\Docker\wsl\data\docker-desktop-data.tar"
Unregister docker-desktop-data from wsl, note that after this, your ext4.vhdx file would automatically be removed (so back it up first if you have important existing image/container):
wsl --unregister docker-desktop-data
Import the docker-desktop-data back to wsl, but now the ext4.vhdx would reside in different drive/directory:
wsl --import docker-desktop-data "D:\Docker\wsl\data" "D:\Docker\wsl\data\docker-desktop-data.tar" --version 2
Start the Docker Desktop again and it should work
You may delete the D:\Docker\wsl\data\docker-desktop-data.tar file (NOT the ext4.vhdx file) if everything looks good for you after verifying
Stop Docker Desktop
Relocate Docker folder from C:\Users\xxx\AppData\Local\Docker to new path
Make sure C:\Users\xxx\AppData\Local\Docker is no longer there
Open a cmd in administrator mode
Run the following command that will create a symbolic link in the cmd window with the appropriate from and to path
mklink /j "C:\Users\xxx\AppData\Local\Docker" "path to where you relocated your docker folder"
Restart Docker Desktop
Edit: re-register docker-desktop would set the default docker-data to C drive now, so we should only unregister docker-data as the accepted answer.
You can do
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data D:\wsl\docker-desktop-data "C:\Program Files\Docker\Docker\resources\wsl\wsl-data.tar" --version=2
The tar file is the file used to install, and before it is your new destination.
This always work while the move-wsl or lxrunoffline didn't work for me on fast rings. And sometimes you have to unistall/install docker first
Extending #Attila Badi 's answer would be to also give the same treatment to the C:\ProgramData\Docker folder, which seems to be used for WSL / Windows Containers. Even moving the Docker data folders, would still leave you with a boot drive ProgramData\Docker folder of massive proportions - especially if you are unable or unwilling to clean the images. You cannot migrate it, or move it once installed. Using the Docker engine advanced settings works in Linux container mode, but not in windows and vice versa and has trouble starting.
Steps I followed:
Uninstall Docker. I know... Make sure you have saved what you need.
Create the primary space-eating docker folders, in a location you have a lot of space, e.g. :
D:\Data\Docker\ProgramData_Docker &
D:\Data\Docker\AppData_Local_Docker
Create linked folders, by running the below in a command window in administrator mode:
mklink /j "C:\Users\xxx\AppData\Local\Docker" "D:\Data\Docker\ProgramData_Docker"
mklink /j "C:\ProgramData\Docker" "D:\Data\Docker\AppData_Local_Docker"
Install Docker.
You should be able to merrily pull windows server images, but not clog up your boot drive.
UPDATE:
Trying to symlink the C:\ProgramData\Docker folder, may result in a security error, depending on the version running depending on the originally installed version.
Release notes for 4.13.0 refers to this feature, which my be a possible work-around (Thanks to #bhagerty and #Oly for the trail):
start /w “” “Docker Desktop Installer.exe” install --installation-dir=G:\Docker
(Source: ungureanuovidiu # https://forums.docker.com/t/docker-installation-directory/32773/17 )
For me docker won't start with junction.
Then I've used just directory symbolic link:
Docker stopped
Folder "wsl" moved to other location on disk "B"
RUben#AD-RUBEN C:\Users\RUben\AppData\Local\Docker
$ mklink /D wsl "B:\dev\wsl"
**symbolic link** created for wsl <<===>> B:\dev\wsl
Containers and Images are ready to use:
A nice tool:
DDoSolitary/LxRunOffline: A full-featured utility for managing Windows Subsystem for Linux (WSL)
https://github.com/DDoSolitary/LxRunOffline
LxRunOffline.exe move Move a distribution to a new directory.
Options:
-n arg Name of the distribution
-d arg The directory to move the distribution to.
for example:
quit docker desktop, then:
wsl --shutdown
LxRunOffline.exe move -n docker-desktop-data -d D:\vm\dockerdesktop\wsl\data
I found this tool from pxlrbt on github. It's using standard wsl import/export and pretty safe. Just moved both my docker-desktop-data distro to a different drive and it works well.
The best option is to update the registry. Follow the below steps
Shutdown the wsl. Use the command wsl --shutdown.
Move the entire C:\Users\%USERPROFILE%\AppData\Local\Docker directory to different drive for example D:\Docker.
Goto Registry editor location Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss.
Find the registry entry with the BasePath set to C:\Users\%USERPROFILE%\AppData\Local\Docker\wsl\data. Update this D:\Docker\wsl\data.
Find another registry entry with the BasePath set to C:\Users\%USERPROFILE%\AppData\Local\Docker\wsl\distro. Update this D:\Docker\wsl\distro.
Restart wsl using: wsl -d Ubuntu.
In Windows 10 home, docker desktop creates the VM under ""C:\Users\xxx\AppData\Local\Docker" directory and it is this VM that contains the downloaded docker images. If you want to change the VM location from C: to a different directory you can do this by creating a junction on windows (prior to docker desktop installation) using a command like below:
mklink /j "C:\Users\xxx\AppData\Local\Docker" "D:\Users\xxx\AppData\Local\Docker"
Note that prior to executing the command the target directory structure should exist while you should delete the C:\Users\xxx\AppData\Local\Docker directory if it exists already else the command could fail. Now install docker desktop on windows 10 home and voila you can see stuff inside "D:\Users\xxx\AppData\Local\Docker" directory namely the docker VM hard disk image file that is going to contain all the downloaded docker images.
Using small SSD also you may want to relocate WSL swap file location.
https://learn.microsoft.com/en-us/windows/wsl/wsl-config

Gazebo stuck at loading your world

https://i.imgur.com/hYf1Bes.jpgm
I am trying to set up ROS and Gazebo in a VM running Ubuntu.
The goal is that I want to simulate Turtlebot with the open manipulator.
I installed everything without any issues.
Though I am not able to launch the Turtlebot environment on Gazebo (like here: http://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/)
$roslaunch turtlebot3_fake turtlebot3_fake.launch
results in Gazebo staying forever in the state loading your world. After some time, it stops responding.
Launching the empty world however works.
I am using ROS 1 with Gazebo 7.0
My hardware setup:
MacBook Pro 13" 2019 with 16 GB RAM
Parallels VM: 3D virtual. ON, no performance limit, 4 CPU kernels, 12 GB RAM enabled
Thank you so much for your help.
After every change you made source your bash and make sure to run :
catkin make
if you've done this already then check if ros is installed properly by running
roscore
on one terminal and let it stay running.
After that try to launch your turtlebot on another terminal.
If it doesnt work even you have installed all of the needed things, i think the problem is with your VM, id recommend you to run ROS on Ubuntu running USB Stick.
cd ~/.gazebo/
mkdir models
cd models/
wget http://file.ncnynl.com/ros/gazebo_models.txt
wget -i gazebo_models.txt
ls model.tar.g* | xargs -n1 tar xzvf
try this gazebo try to download to packages that's why it waits u need internet for that this may take few mins

Mount directory as volume in Docker on Windows 10

I installed Docker on Windows 10 but I have an problem with mount directory (docker it is installed with virtualbox).
I want to mount this path -v /D/www/project_name:/usr/public/www . But I can not do that because I don't have permission.
If I try to mount -v /C/Users/Public/test:/usr/public/www, that works.
How can set permission on partition D? or on path D:www/project_name.
Thanks!
Under windows 10 with the recent versions of docker (which relies on Hyper-V and not VirtualBox) you do not have this kind of issues anymore.
But if you do not have the choice, you should to mount shared directories into virtual box as shown there : http://developmentalmadness.com/2016/03/05/docker-permanently-mount-a-virtualbox-shared-folder/

Docker: Mount volume from Windows host

I use 1.12 version of Docker on Windows, since I can't use the Hyper-V feature with the newer "native" version - so I have my quickstart terminal and communicate to docker host via the invisible underlying virtual box.
Now I have the problem, that I need to mount a local folder to a container, which worked successfully from within the docker-machine by adding
--volume="`pwd`:/root/data"
to the docker run command, but it does not when I launch the same command from my Windows quickstart terminal (even though pwd command works correctly in the terminal).
I tried to find the Windows specific settings for the directory and tested several combinations of format, but no luck. Can anyone help me out on how to correctly specify a Windows folder (e.g. C:\Users\alexander.ruehl) for the volume parameter?
You can use relative path for your volume : --volume="./mydata:/root/data"
Also make sure that you have given the permission for read/write to Docker.

Run a docker container in Windows

I have a Linux x86 application inside a docker container and I want to run it under Windows. I don't want to force users to install Virtual Box. Ideally a qemu or similar virtualization tool can be used, since it is very tiny and requires no installation at all.
My approach was to use qemu for Windows and
boot2docker, so I can boot a minimal Linux with docker installed and than run my docker container within it.
This is the command I'm using to run it:
qemu-system-x86_64.exe -m 256 -cdrom boot2docker.iso
The boot goes well, but I have several problems:
at every boot the image goes trough all the configuration steps (generating keys for ssh, setting hostname, etc.) that can be skipped the second time the image runs; seems that the changes to the image are not persisted trough runs. I want to build an image that is already configured and needs only to boot;
to add my application inside the image I have to rebuild the whole boot2docker.iso image by using the steps described in How to build boot2docker.iso locally.
So, the question is: how can I use the base boot2docker.iso image and add some persisting data (such as configurations and my application)? Perhaps a read/write partition mounted from another file?
like the idea.
Maybe you can check MobaliveCD, it has a nice lightweight GUI and it embeds qemu system inside. I tried it for tinycore live cd iso (base of boot2docker), which works quite ok.
While it seems it doesn't support 64bit (which boot2docker needs), but the function fits for you need.
Your command
qemu-system-x86_64.exe -m 256 -cdrom boot2docker.iso
launches an ISO, what you want is
reserve some disk place for this iso in a .img
run this iso and install it in this .img
reboot
In a Linux you would start by doing
qemu-img create -f qcow2 /home/myuser/my_image.img 6G
There is docker-cli for Windows, it seems to be what you look for, see
http://azure.microsoft.com/blog/2014/11/18/docker-cli-for-windows-clients/
You can use boot2docker http://boot2docker.io/
On boot2docker installation, it will install virtualbox behind the scenes.
You only have to start the boot2docker shortcut and the virtual box management and vms are hidden.

Resources