Remove Docker Base Image

Hi all,
I have created a base Ubuntu image in Docker and after customizing it, I have exported the image to a new image by using “Docker commit” command.
Now I have my base image and my customized image.
I no longer need my base image and I only want to merge everything in my latest customized image.
I cannot delete the base image as my customized image depends on it as it is the parent of it.

Is there any way to merge all changes to my latest image and remove the base and older images?
Can you please assist if this approach is correct?

Many thanks

images consists of layers. your image just adds a layer to the base image, so you cannot delete the base.
What you could do is export the whole image and then import it again or to shrink everything into one layer.

Many thanks for your reply.
It makes scene. I read about the export but to be honest do not know what is the practical way for doing that.
Export apparently saves all my filesystem as a tar file, but how I can use it after?
May I kindly ask you to help if you know the command that I have to use to export or shrink everything to one layer?

Many many thanks…

UPDATE: I think I could manage to do that.
First I did this command to create a new flattened image:
docker export CONTAINER_ID | docker import - some-image-name:version
Then it created a new image called: some-image-name:version
Then I removed the old container:
docker rm CONTAINER_ID
and removed the old image:
docker rmi OLD_IMAGE_ID
and started a new container with docker run…:
docker run options -d -t some-image-name:version
options: like, --net=host

Can anyone please confirm if this approach is correct?!
Thanks,

keep an eye on automation:

write a Dockerfile like.

FROM your-base-image

RUN Your-command-to-change-the-base

build it with docker build --squash.