3531. Creating Docker Machine with More Disk SpaceDocker Machine and Docker
Create new Docker Machine with more memory and disk space assigned.
1. Introduction
When trying to install the image of mssql-server-linux
(Official SQL Server image from Microsoft) in Kitematic, I got the following error.
failed to register layer: Error processing tar file(exit status 1): write /opt/mssql/lib/system.common.sfp: no space left on device
2. Diagnosis
The cause is obvious - disk in docker machine is out of space.
2.1 Storage of Virtual Machine
In VirtualBox, you see the VM named default
. It was initially created when we install the Docker Toolbox. The storage size is 19.53GB.
You can also check this size by selecting the default
VM, then Settings -> Storage.
2.2 Disk Space of Docker Machine
The docker machine is actually hosted by the default
virtual machine. In terminal, SSH into docker VM.
$ docker-machine ssh default
Inside the docker VM, run df -h
or df -i
to get an overview of the disk space. /dev/sda1
is used by docker.
docker@default:~$ df -h
2.3 Solution
Now we are running out of space in the Docker machine, we can delete some Docker images and containers to save some room. However, this is just a workaround.
The better solution is to have more storage for our docker machine. Unfortunately, there is no easy way to increase the disk space for the existing docker machine. Instead, we have to create a new docker machine with more space assigned initially. One limitation of Kitematic is, it always connects to the VM named default
. There is no way to make Kitematic use another docker machine, so we have to delete the old one and create a VM with the same name ‘default’.
3. Re-creating Docker Machine
Warning: The operations below will destroy all docker images and container in 'default' VM. Backup them before proceeding!!!
3.1 Cloning Virtual Machine
Clone the current default VM in case we need to restore the docker machine. Backup data if you are using sort of database containers, like MySQL, MongoDB, etc.
3.2 Deleting Virtual Machine
In VirtualBox, delete the ‘default’ VM.
3.3 Deleting Docker Machine
Check all existing docker machines.
$ docker-machine ls
Delete the docker machine named default
.
$ docker-machine rm default
3.4 Creating New Docker Machine
Create a new docker machine with name=default
, memory size=8GB
and disk size=100GB
.
$ docker-machine -D create -d virtualbox --virtualbox-memory 8096 --virtualbox-disk-size "100000" default
After the creation is done, check the disk space of the new docker machine. Now it has 88GB free space.
In VirtualBox, a new default VM is created. Notice that the storage of it is changed to 97.66
GB.
Open Kitematic, it is running properly and ready for use.
3.5 Installing MSSQL Server
Try to install ‘mssql-serveer-linux’ again. This time, it is successfully installed.
Switch to Settings tab, add new Environment Variable ACCEPT_EULA = Y
, save.
Now, the container for MSSQL Server is running. One issue is, the IP address of docker machine becomes 192.168.99.101.
If you check with docker-machine ls
command, you will see the same IP address.
4. Resetting IP Address for Docker Machine
If you want the original IP address 192.168.99.100 back for the docker machine, take the following actions.
4.1 Resetting IP Address
Run the following command to reset the IP address of default
docker machine to 192.168.99.100
.
$ echo "ifconfig eth1 192.168.99.100 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh default sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
4.2 Regenerating Certificates
Regenerate TLS certificates and update the machine with new certs.
$ docker-machine regenerate-certs default
4.3 Verifying IP Address
Reboot the virtual machine. Check the docker machine again, you will see the IP address is changed to 192.168.99.100
.
In Kitematic, same original IP.
If you get any error, try to regenerate certificates one more time.