I ran this command in my home directory:
docker build .
and it sent 20 GB files to the Docker daemon before I knew what was happening. I have no space left on my laptop. How do I delete the files that were replicated? I can't locate them.
What happens when you run docker build .
command:
Dockerfile
at the same directory where your command runs. If that file doesn't exists, an error is thrown..dockerignore
. If that file exists, Docker client uses that in next step. If not exists nothing happens.tar
package called build context
. Default, it includes everything in the same directory with Dockerfile
. If there are some ignore
rules in .dockerignore
file, Docker client excludes those files specified in the ignore
rules.build context
to Docker engine which named as Docker daemon
or Docker server
.build context
on the fly and starts building the image, step by step defined in the Dockerfile
.build context
is released.So, your build context is not replicated anywhere but in the image you just created if only it needs all the build context. You can check image sizes by running this: docker images
. If you see some unused or unnecessary images, use docker rmi unusedImageName
.
If your image does'nt need everything in the build context, I suggest you to use .dockerignore
rules, to reduce build context
size. Exclude everything which are not necessary for the image. This way, the building process will be shorter and you will see if there is any misconfigured COPY
or ADD
steps in the Dockerfile
.
For example, I use something like this:
# .dockerignore
* # exclude everything
!build/libs/*.jar # include just what I need in the image
Likely the space is being used by the resulting image. Locate and delete it:
docker images
Search there by size
column.
Then delete it:
docker rmi <image-id>
Also you can delete everything docker-related:
docker system prune -a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With