Skip to content

Instantly share code, notes, and snippets.

@gladiopeace
Forked from hayderimran7/docker-btrfs-ubuntu
Created July 1, 2017 17:00
Show Gist options
  • Save gladiopeace/6285917aa41c00b3f0ed11a9ae6749cc to your computer and use it in GitHub Desktop.
Save gladiopeace/6285917aa41c00b3f0ed11a9ae6749cc to your computer and use it in GitHub Desktop.
HOWTO Docker with BTRFS on ubuntu
This is my personal guide on how i setup docker with BTRFS on ubuntu support.
Follow along the steps mentioned as:
1) Make sure you have a separate unmounted partition /dev/sdaX. How I did was , i installed ubuntu on my complete hard drive of 500GB. I wanted to partition it into two, so other 250GB will have btrfs eventually enabled on it. To partition it , after Ubuntu 14 installation, i followed the exact steps as these http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/.
2) Following the above linked guide, i then managed to have two 250GB , one was spare , other was where UBuntu was installed.
3) login to your ubuntu, now create the btrfs filesystem on the other device. To know which device is it,
install gparted :
> sudo apt-get install gparted
> open it as "gparted"
> this will show u all drives , the ones you are on currently with ubuntu will have label "boot" . now take note of other 250G device.
Mine was /dev/sda3.
4) now format that /dev/sda3 with btrfs:
> sudo apt-get install btrfs-tools
> sudo mkfs.btrfs -f /dev/sda3
5) After the partition of btrfs is done on that partition, time to mount /var/lib/docker . At this point, i assume you dont have docker installed at all, since you wana start docker on btrfs from scratch. so first:
> sudo mkdir /var/lib/docker
> sudo mount /dev/sda3 /var/lib/docker
6) now get docker binary directly instead of installing from apt ( i prefer using binary directly ; not from pacakage manager;) )
> sudo wget https://get.docker.io/builds/Linux/x86_64/docker-latest -O /usr/bin/docker
> sudo chmod +x /usr/bin/docker
7) Now properly mount cgroup, this step is really important ; aint easy to find on internet :D
> sudo -i; echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
> mount /sys/fs/cgroup
8) now is the time to start docker daemon :
> docker -d -s btrfs &
if everything works out, you see "daemon has completed initialization" and there it is , your docker running on btrfs using ubuntu. :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imranhayder@imranhayder-VPCSA290X:~$ sudo docker info
Containers: 0
Images: 0
Storage Driver: btrfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.16.0-43-generic
Operating System: Ubuntu 14.04.1 LTS
CPUs: 4
Total Memory: 3.778 GiB
Name: imranhayder-VPCSA290X
ID: S3GD:YBU2:J5TA:NCB4:Q5IY:ITAL:OJKJ:4B53:CIM6:44A6:V7UP:JCN6
WARNING: No swap limit support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
see Storage Driver above?? you are welcome :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment