What do these random-looking repository names mean in Docker? - image

maybe this is a duplicate but I couldn't find any reference for this.
I don't understand what are this images that I see in the output of docker images ls. In the repository column I see some images with a hash in their names.
Thanks!

If you're iterating on a custom image, when you docker build -t imagename ., the imagename:latest tag moves to the newly built image, and the previous image is left behind with just a hash and no other name. You can assign a name to the old image with docker tag, or delete it with docker rmi.
If you are on Docker 1.13 or newer (including any date-format version like 2017.12) then you can ask Docker to clean up the untagged images with
docker image prune
On all Docker versions you can delete the untagged images with the longer
docker images -q -f dangling=true | xargs docker rmi

I found out where the images come from, they are built by Jenkins.

Related

Find out the source repository that a docker image was pulled from

my understanding is that you can install a docker image from different repositories. No surprise there. What surprises me is that there isn't an easily accessible command that tells me that an image has been pulled from a certain registry i.e. some .
How do I get that information?
Do not confuse repositories with registry.
A Docker repository is where you can store 1 or more versions of a specific Docker image.
This information for an image can be found by running
docker images ls -a
On the other hand a registry will consist of multiple repositories which contain images related to a specific project.
Please see the difference here
If you need to find which registry your docker instances is pointing to, run the below command
docker info

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.

Pulling from a local docker image instead

I have an app with a Dockerfile content that looks like
Dockerfile
FROM SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE
COPY docker/app/bin/startup.sh /usr/bin/
CMD ["/usr/bin/startup.sh"]
I don't want to pull the image from amazon anymore instead I'd like to "pull" from the already-existing local image pulled the after the first docker-compose up --build command was ran.
When I do docker images I get
SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name SOME_HEX_VALUE SOMESHORT_HEX 2 days ago 1.54 GB which means the image is local already. I understand this
if the host has the image you want docker-compose to use on it it will use that image but if the host doesn't have it, it will go to docker hub or whatever you have setup in your config for registries
So I changed the Dockerfile content to this:
FROM IMAGE_ID:SOME_HEX_VALUE where IMAGE_ID is the image id of the repository I want when I do docker images but then I get Service 'app' failed to build: repository SOMESHORT_HEX not found: does not exist or no pull access and I'd like to know how to tell Docker to use the local image instead of trying to pull from the amazon url. Any ideas?
First pull the images from the remote repository in your local Docker engine:
docker pull SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE
Now, give the image a new local tag:
docker tag SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE my-image-name
Now you can simply refer to my-image-name, as in:
FROM my-image-name
You should:
FROM IMAGE_ID
Or, this is already ok:
FROM SOME_NUMBERS.dkr.ecr.us-east-1.amazonaws.com/app_name:SOME_HEX_VALUE
Where SOME_HEX_VALUE is the tag version (the second column in docker images). Note that if the images is present in your computer, docker won't try to pull it again.

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

How to specify docker image path on command line without editing configuration setting?

I have my docker container images in different directories. And I would like to specify the path of the directory in the docker -run command. There is a method to change this path by editing the '-g' option in the configuration file, but it requires to restart the docker deamon. Is there any way to specify the docker image path in the docker-run command itself?
Docker must have the knowledge of not just your image physical location, but its complete tree. because docker image is made up of layers, where each layer is built with one Dockerfile command.
Hence, you should let docker register / know all the images from the directory where the images are present. Moreover, if you have physically copied these images from another machine, they would not work unless they are registered / tagged within Docker engine.
The short answer to your question is NO, it is not possible.
Docker engine itself should manage the images, you could do all what docker engine is doing by changing all the configuration files it maintains internally, because all of them are plain text. But it is definitely not worth your time, and you are better off with docker managing the images itself.

Resources