Docker Image Deleted - docker

I made a goof while trying to rename an image by following the steps on this page that say to create a tag then delete the original
Docker how to change repository name or rename image?
Now when I list the images it doesn't show up anymore. However, when I list the containers the image still shows up.
PS C:\Users\Grail> docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 157be28c0fe3 7 days ago 668MB
fedora latest a368cbcfa678 2 months ago 183MB
PS C:\Users\Grail> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
1ea5ffd50852 157be28c0fe3 "/bin/bash" 7 hours ago Exited (0) 7 hours ago
fb81990e756c 0d120b6ccaa8 "/bin/bash" 10 hours ago Exited (0) 24 minutes ago
081641b3e600 a368cbcfa678 "/bin/bash" 11 hours ago Exited (0) 31 minutes ago
Not only that, the image (0d120b6ccaa8) still shows up in my Docker Dashboard (running on Windows) and I can start/stop it without any problems.
Clearly the image still exists. Can I restore it such that I can see it when I list the images?
Can it be restored from the container?
If it's in a weird state/unrecoverable, how do I actually delete it so it's not taking up space?
Update:
Thanks to #prashanna I went down a path where I exported the container and imported to get the image:
docker export -o mycontainer.tar fb81990e756c
docker import mycontainer.tar

**docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]**
is for creating a new image from a container, meaning when you update or add new config or install new software, thus creating a new template images.
ref:docker commit

Related

Existing docker image not being detected for docker container creation

Currently has following docker images locally:
(tts_test) root#e2e-100-17:~/Documents/tritonTTSdeployment# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
customtritonimagetts latest a34706205a9a 5 minutes ago 17.7GB
tritonserver latest 19817c37bb25 12 minutes ago 8.81GB
registry.k8s.io/kube-apiserver v1.26.1 deb04688c4a3 11 days ago 134MB
registry.k8s.io/kube-scheduler v1.26.1 655493523f60 11 days ago 56.3MB
registry.k8s.io/kube-controller-manager v1.26.1 e9c08e11b07f 11 days ago 124MB
registry.k8s.io/kube-proxy v1.26.1 46a6bb3c77ce 11 days ago 65.6MB
registry.k8s.io/etcd 3.5.6-0 fce326961ae2 2 months ago 299MB
nvcr.io/nvidia/tritonserver 22.10-py3-min 8bc805049606 3 months ago 6.72GB
nvcr.io/nvidia/tritonserver 22.10-py3 486d7ee640ad 3 months ago 13.5GB
registry.k8s.io/pause 3.9 e6f181688397 3 months ago 744kB
registry.k8s.io/coredns/coredns v1.9.3 5185b96f0bec 8 months ago 48.8MB
registry.k8s.io/pause 3.6 6270bb605e12 17 months ago 683kB
gcr.io/k8s-minikube/storage-provisioner v5 6e38f40d628d 22 months ago 31.5MB
Command to create container:
docker run -t customtritonimagetts
Still after trying to run the following command to create docker container, it's not creating the docker container and throwing following error:
Unable to find image 'customtritonimagetts:latest' locally
docker: Error response from daemon: pull access denied for customtritonimagetts, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
earlier i was trying to configure Minikube and might have caused some issues with docker images creation and image registry. What can be possible issues!
[NOTE: there was slight typo error which i corrected and the issue still persist]
Make sure the repository is public, this error means that the docker image you are trying to pull is private.Only logged users with permissions may pull the image.
Try the troubleshooting steps:
1- docker logout
2- docker login --username=YOURUSERNAME Enter password when asked
3- docker pull repositoryName"/"imageName[:tag]
if "tag" is not included the default value will be "latest". Then check the images by docker images command to check if it's been pulled. After pulling it you can make the repository private again.

Kitematic not showing any Images/Containers

I have pulled three images from docker hub using docker.I have listed those three images below
suju#suju-VirtualBox:~$ sudo docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 71b5c7e10f9b 11 days ago 477MB
hello-world latest fce289e99eb9 4 weeks ago 1.84kB
java latest d23bdf5b1b1b 2 years ago 643MB
And i installed kitematic 0.17.6 for purpose of Managing Docker container
but when i open kitematic, it doent show any container, its just shows a white window without any options except exit

How to enable changes in AWX Containers?

I am trying to install additional python packages in AWX container awx_tasks so that the changes could enable the ansible modules like snow, ec2_elb_facts run (which have pre-requisites as Python modules). I have made the changes in the container using:
# docker exec -it 80ab6bf562a9 bash
where 80ab6bf562a9 is the container id for awx_task container.
and then installed the required packages inside the custom virtual environment (as mentioned in the AWX documentation). Post this, i have made the changes permanent by creating a new image with the container changes using:
# docker commit 80ab6bf562a9 ansible/awx_task:latest
Post this, ran the following command to map the new container with the newly created image with container changes.
# docker run --name awx_task -d 5290f9b3268c
Following are the containers post the above changes. Here, the newly created container which was mapped with the new image with changes in existing container is 968fb2a7da2f.
# docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
968fb2a7da2f 5290f9b3268c "/tini -- /bin/sh -c…" 2 days ago Exited (143) 2 days ago awx_task
80ab6bf562a9 535bb2b8e1f3 "/tini -- /bin/sh -c…" 3 weeks ago Up 2 days 8052/tcp awx_task_OLD
aea2551951d5 b7c261b76010 "/tini -- /bin/sh -c…" 3 weeks ago Up 2 days 0.0.0.0:80->8052/tcp awx_web
e789a4a82a9e memcached:alpine "docker-entrypoint.s…" 3 weeks ago Up 2 days 11211/tcp memcached
a8c74584255c ansible/awx_rabbitmq:3.7.4 "docker-entrypoint.s…" 3 weeks ago Up 2 days 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp rabbitmq
25f6f6ca7766 postgres:9.6 "docker-entrypoint.s…" 3 weeks ago Up 2 days 5432/tcp postgres
Following are my images post above changes. Here, the newly created image (with changes) is 5290f9b3268c.
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ansible/awx_task latest 5290f9b3268c 2 days ago 1.48GB
postgres 9.6 106bdfb062df 8 weeks ago 235MB
ansible/awx_task <none> 535bb2b8e1f3 8 weeks ago 1.07GB
ansible/awx_web <none> b7c261b76010 8 weeks ago 1.04GB
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
memcached alpine b40e8fa7e3e5 2 months ago 8.69MB
ansible/awx_rabbitmq 3.7.4 e08fe791079e 6 months ago 85.6MB
The new container is properly mapped with the new image (which has got the changes i wanted). The issue now is that when i stop the old container and start the new container AWX doesn't work. I can just view the UI, if i run any tasks like executing templates, it just freezes. It appears like the new container/images are not talking with the other containers like awx_rabbitmq, postgres etc. I have been reading multiple posts regarding this however, i couldn't find any single post which highlights anything regarding this.
I basically want the changes in the awx_task container to work so that i could achieve the goal of making the custom modules work. Could anyone suggest what can be done so that the new awx_task container could take the role of the older awx_task and AWX could work normally?
Since i found the way to do this, i will share the steps to make the required changes.
The python package versions can be controlled from the requirements directory, AWX Task and AWX Web Images related changes can be applied in the Dockerfile.j2 in the roles directory. Once the required changes are applied, we can run the setup using ansible-playbook install.yml -i inventory.
You should use the install.yml to restart the awx_task container, since it ensures the right environment variables are set, the right volumes are mapped, etc. Same command as you've used to install AWX:
ansible-playbook install.yml -i inventory.
See here for a full list of arguments that are used.

How to link container with a new image?

I am new to Docker and tried to check how to make changes in a docker container and commit them to reflect in the results. I have AWX running on Docker-CE and had created made changes in awx_web container to update the UI logo as mentioned in the Ansible Tower documentation:
docker cp custom_console_logo.png aea2551951d5:/var/lib/awx/public/static/assets
and created the local_settings.json in /var/lib/awx/public/static/ one of the running awx_web container using the following and then using the bash command to create and save file:
docker exec -it aea2551951d5 bash
Post this, i have commited the changes so that the changes are reflected permanently in the image file and in UI using:
docker commit aea2551951d5 ansible/awx_web
I have verified the changes in the container files and it appears to be fine however, the changes are not getting reflected when i verified them on browser. It appears like the existing container is pointing to the old image file:
CONTAINER ID IMAGE
aea2551951d5 b7c261b76010
I am not sure what was missed. Could anyone suggest if i have missed anything and how do i fix this?
Following are the containers:
[root#localhost~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80ab6bf562a9 ansible/awx_task:latest "/tini -- /bin/sh -c…" 13 days ago Up 3 days 8052/tcp awx_task
aea2551951d5 b7c261b76010 "/tini -- /bin/sh -c…" 13 days ago Up 3 hours 0.0.0.0:80->8052/tcp awx_web
e789a4a82a9e memcached:alpine "docker-entrypoint.s…" 13 days ago Up 3 days 11211/tcp memcached
a8c74584255c ansible/awx_rabbitmq:3.7.4 "docker-entrypoint.s…" 13 days ago Up 3 days 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp rabbitmq
25f6f6ca7766 postgres:9.6 "docker-entrypoint.s…" 13 days ago Up 3 days 5432/tcp postgres
Following are the Images:
[root#localhost~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ansible/awx_web latest 1accc59cbdee 2 hours ago 1.06GB
b7c261b76010 latest 998ec3e77fd8 3 hours ago 1.06GB
postgres 9.6 106bdfb062df 6 weeks ago 235MB
ansible/awx_task latest 535bb2b8e1f3 6 weeks ago 1.07GB
ansible/awx_web <none> b7c261b76010 6 weeks ago 1.04GB
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
memcached alpine b40e8fa7e3e5 2 months ago 8.69MB
ansible/awx_rabbitmq 3.7.4 e08fe791079e 5 months ago 85.6MB
[root#clab2726vw0001 ~]#
Environment Information:
Docker Version: 18.06.0-ce, build 0ffa825
AWX Version: 1.0.6.41
Ansible Version: 2.6.1
RHEL Version: Red Hat Enterprise Linux Server release 7.5 (Maipo)
Containers are the running instances of images and the container id is unique for the particular image.
We cannot use the same 12 digit container id as a reference for the other images. When we use "commit" it create a new fresh container for the new image.
This new container will contain all the changes needed.
You can try with naming the container.
Give a name to container (using docker rename command) .
Make your changes in container.
Commit it.
Give same name to new container generated for the new image.
Rename old container with some other name.
Now you have the same container name (as you were using before) but with new Image.

Specify Container ID of docker process to attach

On my remote server, some developers run the same docker images named "my_account/analysis". So, once detached from the docker process, it is struggling to know which is my own process.
The result of docker ps is like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6968e76b3746 my_account/analysis "bash" 44 hours ago Up 44 hours 6023/tcp, 6073/tcp, 6800/tcp, 8118/tcp, 8888/tcp, 9050/tcp, 0.0.0.0:8887->8887/tcp modest_jones
42d970206a29 my_account/analysis "bash" 7 days ago Up 7 days 6023/tcp, 6073/tcp, 6800/tcp, 8118/tcp, 8888/tcp, 9050/tcp, 0.0.0.0:32771->8885/tcp gallant_chandrasekhar
ac9f804b7fe0 my_account/analysis "bash" 11 days ago Up 11 days 6023/tcp, 6073/tcp, 6800/tcp, 8118/tcp, 8888/tcp, 9050/tcp, 0.0.0.0:8798->8798/tcp suspicious_mayer
e8e260aab4fb my_account/analysis "bash" 12 days ago Up 12 days 6023/tcp, 6073/tcp, 6800/tcp, 8118/tcp, 8888/tcp, 9050/tcp, 0.0.0.0:32770->8885/tcp nostalgic_euler
In this case, because I remember that I ran docker around 2 days ago, I attach my container by docker attach 6968e. However, usually we forgot this.
What is the best practice to detect the container ID of mine under the situation that there are a lot of containers with the same Image name?
The simple way is to name the containers
docker run --name my-special-container my_account/analysis
docker attach my-special-container
You can store the container ID in a file when it launches
docker run --cidfile ~/my-special-container my_account/analysis
docker attach $(cat ~/my-special-container)
You can add more detailed metadata with object labels, but they are not as easily accessible as names
docker run --label com.rkjt50r983.tag=special my_account/analysis
docker ps --filter 'label=com.rkjt50r983.tag=special'

Resources