{"id":28032998,"url":"https://github.com/jonasalfredsson/docker-on-tmpfs","last_synced_at":"2025-05-11T09:07:39.749Z","repository":{"id":65158050,"uuid":"460568671","full_name":"JonasAlfredsson/docker-on-tmpfs","owner":"JonasAlfredsson","description":"GitHub Action that mounts a tmpfs volume on /var/lib/docker/.","archived":false,"fork":false,"pushed_at":"2022-02-22T06:36:19.000Z","size":10,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T09:07:28.103Z","etag":null,"topics":["386","armv7","cryptography","docker","getdents64","github-actions","hacktoberfest","qemu","readdir","tmpfs"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JonasAlfredsson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-17T18:59:23.000Z","updated_at":"2023-09-01T00:13:51.000Z","dependencies_parsed_at":"2023-01-05T04:49:22.752Z","dependency_job_id":null,"html_url":"https://github.com/JonasAlfredsson/docker-on-tmpfs","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasAlfredsson%2Fdocker-on-tmpfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasAlfredsson%2Fdocker-on-tmpfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasAlfredsson%2Fdocker-on-tmpfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasAlfredsson%2Fdocker-on-tmpfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonasAlfredsson","download_url":"https://codeload.github.com/JonasAlfredsson/docker-on-tmpfs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253540829,"owners_count":21924537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["386","armv7","cryptography","docker","getdents64","github-actions","hacktoberfest","qemu","readdir","tmpfs"],"created_at":"2025-05-11T09:07:38.973Z","updated_at":"2025-05-11T09:07:39.743Z","avatar_url":"https://github.com/JonasAlfredsson.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-on-tmpfs\nGitHub Action which mounts a tmpfs volume on `/var/lib/docker`.\n\nThis action was created to solve a [very specific problem][1] that occurs when\nbuilding the latest pip `cryptography` package inside a QEMU emulated\n`linux/arm/v7` environment (e.g. Rasberry Pi) on a `linux/amd64` computer.\n\nThe compilation of the package fails because some weirdness inside a low level\nlibrary when it tries to read the filesytem while running inside a 32-bit\nenvironment that is emulated by QEMU running on a 64-bit host. Apparently a\nworkaround for this is to swap the filesystem to a tmpfs one in order to not\ntrigger this bug, so we make the entire `/var/lib/docker` folder like that.\n\nHere are links to the biggest threads discussing this issue further:\n\n- https://github.com/docker/buildx/issues/395\n- https://github.com/rust-lang/cargo/issues/8719\n- https://gitlab.com/qemu-project/qemu/-/issues/263\n\n\n### Acknowledgments and Thanks\n\nThis action has been inspired by the workarounds posted in the threads mentioned\nabove, but there are three solutions I would like to give extra credit to:\n\n- [`@pierotofy`][4]: For showing how to configure the swap space.\n- [`@easimon`][5]: For providing details about GitHub runners.\n- [`@nijel`][6]: For showing how a `tmpfs` can be used as a workaround.\n\n\n## Usage\n\n\u003e :warning: Please read the [More Information](#more-information) section to\n            understand the physical limitations of the GitHub runners before\n            changing the values.\n\n```yaml\n- name: Run Docker on tmpfs\n  uses: JonasAlfredsson/docker-on-tmpfs@v1\n  with:\n    tmpfs_size: 5\n    swap_size: 4\n    swap_location: '/mnt/swapfile'\n```\n\n\n## More Information\n\nThe official [specifications][2] of GitHub runner machines are the following:\n\n- 2-core CPU\n- 7 GB of RAM memory\n- 14 GB of SSD disk space\n\nHowever, this does not paint the whole picture, and a more detailed\nrepresentation of a newly starter runner would be this:\n\n#### CPU\n```\nvendor_id\t: GenuineIntel\ncpu family\t: 6\nmodel\t\t: 85\nmodel name\t: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz\ncpu MHz\t\t: 2095.197\ncache size\t: 36608 KB\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt avx512cd avx512bw avx512vl xsaveopt xsavec xsaves md_clear\nbugs\t\t: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit\n```\n\n#### Memory\n\n```\n              total        used        free      shared  buff/cache   available\nMem:          6.8Gi       484Mi       5.3Gi       9.0Mi       1.0Gi       6.0Gi\nSwap:         4.0Gi          0B       4.0Gi\n```\n\n```\nNAME          TYPE SIZE USED PRIO\n/mnt/swapfile file   4G   0B   -2\n```\n\n#### Storage\n\n```\nNAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nsda       8:0    0   14G  0 disk\n└─sda1    8:1    0   14G  0 part /mnt\nsdb       8:16   0   86G  0 disk\n├─sdb1    8:17   0 85.9G  0 part /\n├─sdb14   8:30   0    4M  0 part\n└─sdb15   8:31   0  106M  0 part /boot/efi\n```\n\n```\nFilesystem      Size  Used Avail Use% Mounted on\n/dev/root        84G   53G   31G  63% /\ndevtmpfs        3.4G     0  3.4G   0% /dev\ntmpfs           3.4G  4.0K  3.4G   1% /dev/shm\ntmpfs           695M  1.1M  694M   1% /run\ntmpfs           5.0M     0  5.0M   0% /run/lock\ntmpfs           3.4G     0  3.4G   0% /sys/fs/cgroup\n/dev/sdb15      105M  5.2M  100M   5% /boot/efi\n/dev/sda1        14G  4.1G  9.0G  32% /mnt\n```\n\n#### Default Workspace\n\nThere is one variable that is extra interesting of those listed [here][3], and\nthat is `GITHUB_WORKSPACE` which is explained like this:\n\n\u003e Actions and shell commands execute in this directory. An action can modify\n  the contents of this directory, which subsequent actions can access.\n\nThis path defaults to\n\n    /home/runner/work/\u003crepo-name\u003e/\u003crepo-name\u003e\n\nso in this repository's case it would be\n\n    /home/runner/work/docker-on-tmpfs/docker-on-tmpfs\n\nThis is also the path you will get if you run just `echo ${PWD}`.\n\n### Limitations\n\nWith the above information we can see that, by default, we are not using the\nadvertised 14G available on `/mnt`, but instead the 31G on `/`. Furthermore,\nof those 14G on `/mnt` 4 are used for the swap file, so it is really only 10G\navailable there. At startup we are also using ~0.5G RAM, which means that we\nhave about 6G to play with for our `tmpfs` volume.\n\nWhat is important to understand is that a `tmpfs` volume writes its data to RAM,\nso if you consume more than the available the system will start moving data to\nthe swap file on the disk. Reading data from disk is **brutally** slow compared\nto accessing it from RAM, so when this happens the system might become unusable\nslow. However, if you remove the swap file and fill up the RAM the system will\nprobably crash so it is important to keep if we are to do what this action does.\nLinux is also pretty clever, so data more frequently accessed is less likely to\nbe pushed to swap.\n\nI would suggest you try to keep `tmpfs_size` as small as possible for your\ntask, in order to minimize the risk of starving the other system processes.\nA good thing to do is also to keep the `swap_size` the same size as your\n`tmpfs`, and this is even more important in case you want to make the volume\nlarger than the currently available RAM.\n\n\n\n\n\n\n[1]: https://github.com/JonasAlfredsson/docker-nginx-certbot/issues/30\n[2]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners\n[3]: https://docs.github.com/en/actions/learn-github-actions/environment-variables\n[4]: https://github.com/pierotofy/set-swap-space\n[5]: https://github.com/easimon/maximize-build-space\n[6]: https://github.com/WeblateOrg/docker/pull/1274/commits/c40a9949596cee31d6a56597e5e3480e0b090d25\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasalfredsson%2Fdocker-on-tmpfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasalfredsson%2Fdocker-on-tmpfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasalfredsson%2Fdocker-on-tmpfs/lists"}