Docker how to clean partial failed downloads for images? - macos

I am using docker toolbox in OS X. When I run docker-compose pull and the network cuts out, the download does not resume after I fix the issue. Is there a way to purge or invalidate partial downloads for docker images?

As noted in the comments, incomplete images would not be present anyway.
Since PR 18353 and docs-v1.11.2-2016-06-10, the next pull would reload missing/incommplete layers and build the complete image.
For purging images (dangling or not used): docker image prune -a
For purging containers: docker container prune
See more here.

Related

How do I uninstall Docker packages?

I wanted to install CVAT for training an Object Detection AI using Docker. The install failed for some reason in the middle and it wasn't installed. But all the files were still occupying space on my machine. I tried reinstalling the CVAT and the files keep adding to the occupied space. How do I remove all of these files? I am using a MacBook Pro with MacOS Big Sur Beta 4.
Edit: https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/installation.md#mac-os-mojave
These are the commands I am running to install CVAT.
docker-compose build output: https://pastebin.com/7EkeQ289
docker-compose up -d output: https://pastebin.com/hF3GFDkX
docker exec -it cvat bash -ic 'python3 ~/manage.py createsuperuser output: https://pastebin.com/Mfh8CivL
If you are trying to remove the containers, attempt the following:
1. docker ps -a - lists all containers
2. docker stop [label or SHA of the containers you want to remove]
docker-compose down [YAML configuration file you targeted with docker-compose up] - this should stop all containers, teardown networks, etc. that docker-compose started with 'up'
docker container prune - removes all stopped containers
NOTE: If you have other stopped containers that you want to keep, do not run this, but remove them individually, as I suggested in the stricken-through step two above, or Konrad Botor's comment
https://docs.docker.com/compose/reference/down/
https://docs.docker.com/engine/reference/commandline/container_prune/
If you want to remove the images:
docker images
docker rmi [label or SHA] (RMI is the remove image command)
https://docs.docker.com/engine/reference/commandline/images/
https://docs.docker.com/engine/reference/commandline/rmi/
To speed up this process, analyze the YAML configuration file being targeted for your docker-compose build command, and/or reference the documentation for that specific project (CVAT) if available, to determine what containers (software) it is initializing (and how it is doing so, if necessary). It might help to paste its contents in the question.
Note: what is taking up space may be volumes which are not cleaned up properly by the docker build scripts for this project. See the following documentation on how to remove those:
https://docs.docker.com/engine/reference/commandline/volume_rm/
I might be missing some context, as I cannot access your pastebin links (behind a firewall at the moment).

How to delete images on disk for Docker mac?

I see a lot of info on deleting Docker images and containers that are 'dangling/unused', but how can I delete images that aren't running as a container that I've downloaded using docker-compose -f my-compose-file.yaml?
When I exec 'docker system prune', and then run docker-compose again, I'm getting messages that the images already exist. I'm trying to remove all existing images from my system that were previously downloaded with 'docker-compose'.
Check this Post. It'll give you a good idea on how to deal with images.
Or in short and general:
docker rmi $(docker images -aq)
You can clean up docker artifacts by using the following command (depending on what you need to clean up):
docker container prune
docker image prune
docker network prune
docker volume prune
These commands support '-a' option that will delete all of the artifacts if specified (for example docker container prune -a will remove all the containers)
In case you need to clean up everything you may want to use:
docker system prune -a
The description of docker system prune in the docs is very brief
Remove unused data
Can you try running docker system prune --all which according to the docs removes all unused images, the options for --all flag
--all , -a Remove all unused images not just dangling ones
You could also try using docker image prune --all which is used to delete only unused images, for more see this.
I am new to Docker and still learning it.. Why not try docker image prune -a for removing unused images which are not being referenced by any container, for details see this . Although I think that your docker system prune should have worked.

Copy files to docker image after build

I do have an already build docker image and wan't to add files to it AFTER the build was done. Is there a way to add files without rebuilding it (or maybe to add it and save it with an new tag)? I did find docker cp but if I understand that right it does only work in running containers.
docker cp but if I understand that right it does only work in running containers
Still, that might work considering you can then commit a container into a new image.
See docker commit.
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

ingensi/play-framework image repetitive downloads

I have docker running on a windows box successfully. When I try to docker build . an image, docker downloads a lot of large image files in step 1.I have no problem with this. However, the last time I tried, I got an unexpected interruption when all but one image file was remaining to download. When I built again, all the downloads started afresh and this has happened again and again. My question is, does docker not cache the already downloaded files somewhere or is there not a way to avoid this repetitive download? Here is my Dockerfile
# Dockerfile
FROM ingensi/play-framework
COPY activator.sh /activator.sh
EXPOSE 8000
RUN mkdir /app
WORKDIR /app
CMD ["activator","run"]
This is the console output on running docker build .
Sending build context to Docker daemon 7.543 MB
Step 1 : FROM ingensi/play-framework
latest: Pulling from ingensi/play-framework
a3ed95caeb02: Pull complete
6b8936f53711: Downloading 10.77 MB/77.28 MB
ba9b63c22e85: Downloading 8.222 MB/18.17 MB
c8f760722057: Download complete
05c3b10b9cd9: Waiting
eea97537ef12: Waiting
40254e2b433f: Waiting
66be6357e6af: Waiting
ca0f372c20c8: Waiting
1f9b623e6354: Waiting
The image files being downloaded are always the same and appear in the same order judging by the codes on the left and file sizes.
It's unclear what part of your Dockerfile would cause files to download. Note that Docker will cache image layers, not files that are downloaded to create layers. Details on how to take advantage of that are here: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache
When I built again, all the downloads started afresh and this has happened again and again.
My question is, does docker not cache the already downloaded files somewhere?
Yes, images are stored in a cache folder.
See "Where are docker images stored on the host machine?"
In your case, you might use Docker for Windows which requires Microsoft Hyper-V to run.
There are caching issue, but only for Docker cloud, not locally.
I advised in the comment:
docker-machine ssh
cd /C/Users/<yourLogin>/path/to/your/project
docker build

I can't find my Docker image after building it

I'm new to Docker, so please allow me to describe the steps that I did. I'm using Docker (not Docker toolbox) on OS X. I built the image from Dockerfile using the following command
sudo docker build -t myImage .
Docker confirmed that building was successful.
Successfully built 7240e.....
However, I can't find the image anywhere. I looked at this question, but the answer is for Docker toolbox, and I don't have a folder /Users/<username>/.docker as suggested by the accepted answer.
You would be able to see your docker images by the below command:
docker images
And to check which all containers are running in docker:
docker ps -a
Local builds (in my case using buildkit) will create and cache the image layers but simply leave them in the cache rather than tell the docker daemon they're an actual image. To do that you need to use the --load flag.
$ docker buildx build -t myImage .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Doesn't show anything, but...
$ docker buildx build -t myImage --load .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myImage latest 538021e3d342 18 minutes ago 190MB
And there it is!
There actually is a warning about this in the output of the build command... but it's above all the build step logs so vanishes off your terminal without easily being seen.
To get list of Images
docker image ls
or
docker images
In addition to the correct responses above that discuss how to access your container or container image, if you want to know how the image is written to disk...
Docker uses a Copy on Write File System (https://en.wikipedia.org/wiki/Copy-on-write) and stores each Docker image as a series of read only layers and stores them in a list. The link below does a good job explaining how the image layers are actually stored on disk.
https://docs.docker.com/storage/storagedriver/
As already said, after the docker images
this command will show you all the images you have locally.
i.e "somth like that"
REPOSITORY TAG IMAGE ID CREATED SIZE
codestandars 1.0 a22daacf6761 8 minutes ago 622MB
bulletinboard 1.0 b73e8e68edc0 2 hours ago 681MB
ubuntu 18.04 cf0f3ca922e0 4 days ago 64.2MB
now you should
docker run -it and the IMAGE ID or the TAG related to the repository you want to run.
Command to list the docker images is :
docker images
The default docker images will show all top level images, their repository and tags, and their size.
An image will be listed more than once if it has multiple repository names or tags.
Click here for the screenshot for more details

Resources