Open jianlins opened 3 months ago
I guess it's faster to stop the docker service (if possibile), rename the current /var/lib/docker to something else, run the action, rsync back to the new /var/lib/docker and start docker again
Tried. it doesn't work. I've tried a tone of ways to change docker data root directory, although it works on local machine, it doesn't work in runs. And start docker and stop docker commands behave weirdly. You should give it a try. Maybe there are other ways.
Simply restarting the docker service seems to work for me:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
build-mount-path: /var/lib/docker/
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Restart docker
run: sudo service docker restart
- name: Checkout
uses: actions/checkout@v4
Have you worked further to check the storage? It seems restarted , but still not saving to the mounted folder.
If you want to preserve the contents of /var/lib/docker, I've found that the following snippet seems to work:
- name: Move /var/lib/docker/
run: sudo mv /var/lib/docker/ "${GITHUB_WORKSPACE}/docker"
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 512
temp-reserve-mb: 32
swap-size-mb: 32
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
build-mount-path: '/var/lib/docker/'
- name: Restore /var/lib/docker/
run: sudo sh -c "mv ${GITHUB_WORKSPACE}/docker/* /var/lib/docker"
You shouldn't use remove-docker-images
in this case because it would run docker image prune
, which doesn't work after /var/lib/docker
is moved. You can replicate its behavior by adding a docker image prune --all --force
step beforehand.
The first three steps will work for docker build, can you integrate it into the action?