I needed space and executed: docker rmi $(docker images -f \"dangling=true\" -q)
Since then I can\'t with docker-compose: docker-compose build
there could be several different problems. You can find out the problem by checking the issue that docker build is throwing.
The problem is that docker-compose build will suppress the information of the issue. To find out what the issue is
do not use:
docker-compose build XXX
instead, open your docker-compose.yml, find the build: tag of the service is giving you an issue, e.g.
services:
yourservice:
build: yourservice-directory/
and then run:
docker build yourservice-directory
after this you will see what is the issue.
I had the same issue and the approved answer didn't work for me.
Turns out I had a file with permissions which didn't allow the user running docker-compose to read it. After removing the file everything was OK
Reference:
https://medium.com/the-code-review/clean-out-your-docker-images-containers-and-volumes-with-single-commands-b8e38253c271
1. Clean up containers, images, volumes and networks on your system:
docker system prune --all --force --volumes
2. docker-compose up
I found a temporary solution:
Ensure specify the image name on docker-compose.yml
for example, specify the image name and container_name as django_practice_db/django_practice_web
services:
django_practice_db:
image: postgres
container_name: django_practice_db
django_practice_web:
container_name: django_practice_web
build: .
command: pipenv run python manage.py runserver 0.0.0.0:8000
Copy the project file to another place
Go inside the copied project directory
Execute docker-compose build
Go back to the original project directory
Execute docker-compose up
Not sure why I can build images when I change the folder path.
For me the issue turned out that a Docker Pull was hung, so I CTRL+C'd out of it and tried again. Same error message.
In the end I found some files owned by root in this directory. Giving the files proper permissions fixed the issue.
chown -R <username>:<group> /var/lib/docker/tmp
I tried everything from rebooting, reinstalling Docker, and purging /var/lib/docker
.
My cause was something corrupting the build context in my project. After I ran git clean
to reset the project directory back to its original state, I was able to docker-compose
.
Run git clean -iXd
in your project's root to interactively git clean
.
Edit: after a while, it happened again. This time, git clean
didn't fix it. I'm pretty sure it only happens on Ubuntu. My arch coworkers have never encountered it.