I am generating docker images with the following commands:
docker build --no-cache=true --force-rm -t $TAG .
docker save $TAG | pigz > $DOCKER_CLIENT_NAME
docker image rm -f $TAG
docker --version
Docker version 23.0.6, build ef23cbc
I have two questions:
- can I have the three commands "all at once" with a custom builder? I am quite new to Docker, I saw there are several builder drivers, but I never managed to make the exact same file (.tar.gz with the same format (OCI?)) I only managed to have a direct tar.gz of the file contents, but not the image itself.
- Eventhough I use
--no-cache=true --force-rm
it stills generates a lot of build cache layers. How can I do to not keep them? I have to do adocker system prune -a -f
everyday when idle (I believe it fails when a docker system prune occurs at the same time) I run this in a script ~20 times a day. Thank you!
[root@blabla ~]# docker system df -v
Images space usage:
REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS
Containers space usage:
CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED STATUS NAMES
Local Volumes space usage:
VOLUME NAME LINKS SIZE
Build cache usage: 4.085GB
CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
zbl6sfoi1mnk regular 33.7MB 6 hours ago 6 hours ago 1 false
se5ieou1bpma regular 689MB 6 hours ago 6 hours ago 1 false
bsrwh7g7sm3y regular 45.6kB 6 hours ago 6 hours ago 1 false
7knpo8jf5xgl regular 263MB 6 hours ago 6 hours ago 1 false
9bhm3qvhy1xq regular 24.2kB 6 hours ago 6 hours ago 1 false
p30ycjl5wrny regular 671MB 6 hours ago 6 hours ago 1 false
44n78fr9apyt regular 836kB 6 hours ago 6 hours ago 1 false
bult7i2wuqqu regular 263MB 6 minutes ago 5 minutes ago 1 false
iskdwlnbmjjn regular 45.6kB 6 minutes ago 5 minutes ago 1 false
zc16cmf04wd3 regular 671MB 5 minutes ago 5 minutes ago 1 false
bar49qm3yhfy source.local 0B 6 hours ago 5 minutes ago 2 false
qhtgrakuz0tu source.local 533B 6 hours ago 5 minutes ago 2 false
duvrvuth080e regular 0B 6 hours ago 5 minutes ago 2 false
8oqc9tku8hwe source.local 986MB 6 hours ago 5 minutes ago 2 false
psffwyhk0rtg regular 33.7MB 6 minutes ago 5 minutes ago 1 false
rvojp10g0c3f regular 473MB 6 minutes ago 5 minutes ago 1 false
sgnr8jasgy56 regular 24.2kB 6 minutes ago 5 minutes ago 1 false
tsxslzka1em8 regular 836kB 6 minutes ago 5 minutes ago 1 false
--force-rm
seems to have no effect.
--cache-from type=local,dest=/bla/bla --cache-to type=local,dest=/bla/bla
does not work with docker driver:
ERROR: cache export feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")