Drone

Can't use docker layering ideas To save build push time

Docker push command cannot use docker volume When I use the official docker image in Drone,Drone log like this,

time docker push my personal repository:latest
The push refers to repository [my personal repository]
e46fbc87a7d1: Preparing
2ebbbbe18209: Preparing
9350ad1c5511: Preparing
ac1faac0988e: Preparing
dbc783c89851: Preparing
7bff100f35cb: Preparing
7bff100f35cb: Waiting
dbc783c89851: Layer already exists
ac1faac0988e: Layer already exists
9350ad1c5511: Layer already exists
2ebbbbe18209: Layer already exists
7bff100f35cb: Layer already exists
e46fbc87a7d1: Pushed
latest: digest: sha256:147643e4cdb0b4998cbef901f0e2c7a0d1900af61df9d9fe8c235b72749c7562 size: 1576

real    0m 14.70s
user    0m 0.02s

but when I use it on centos,it will work

time docker push ***/***:latest
The push refers to repository [***/***]
6843aeb04b20: Layer already exists 
863729f338ea: Layer already exists 
e8e12ff076f8: Layer already exists 
ac1faac0988e: Layer already exists 
dbc783c89851: Layer already exists 
7bff100f35cb: Layer already exists 
0.0.2: digest: sha256:a394c3bb02cb228747cea0883c222901dadfff3c2128e367b6498e232aa25eca size: 1576

real    0m2.103s
user    0m0.025s
sys 0m0.034s

Pushing on centos is 12 seconds less than pushing in drone,so my problem is that there is no way to use Docker leyer ideas in Drone.
this is my .drone.yml

- name: Docker build
  image: docker:latest
  pull: if-not-exists
  volumes:
  - name: docker
    path: /var/run/docker.sock
  commands:
    - docker version
    - docker login -u ***  --password *** repository
    - time docker build -f Dockerfile -t ***:latest .
    - time docker push ***:latest
    - docker system prune -f

you are running docker system prune -f which is clearing your local build cache, as a result docker will re-build each layer which could result in different checksum values for the layer, hence why it would re-push the layer every time.

The command we’re going to be executing is docker system prune -f which will remove all stopped containers, all unused networks, all dangling images and build caches.

Also remember that there is no magic happening here. Drone converts your pipeline to a standard docker run command (see below) which means any runtime or performance issues you are experiencing are Docker issues, not Drone issues. If you continue to experience issues you should consider creating a thread in the Docker community support forum.

$ docker run -v /var/run/docker.sock:/var/run/docker.sock docker:docker /bin/sh -c “docker version; docker build …; docker push …; docker system prune -f”