Tuesday, August 13, 2019

Edit, remove, update files in Docker image


One option using dockerfile.

Another option, to create a container and commit that to the image.

docker run -it --name="centos_test" centos:latest /bin/bash

Now, update the files or any changes.

After that, commit the container

docker commit -m="This a test image" centos_test new_centos_image

Here,
-m=”This a test image” : is a Commit message.
centos_test : Name of the container from which you are creating the image.
new_centos_image: Name of the new image created.

Now, push the image using link


To delete images.

For images:
docker images | grep "pattern" | awk '{print $3}' | xargs docker rmi
and alternatively, I found this one to work better (as multiple tags can link to a same image):
docker images | grep "pattern" | awk '{print $1":"$2}' | xargs docker rmi

Reference:
1 2 3

No comments:

Post a Comment