Podman image not updating like it has to

I ran the following commands to change some lines in a file contained in a podman container:

# RUN THE IMAGE
podman run -it opensearchproject/opensearch-dashboards:1.2.0 /bin/bash

# READ CONTENT 

cat config\opensearch_dashboards.yml

# OLD CONTENT

while IFS='' read -r a; do
    echo "${a//localhost/0.0.0.0}"
done < opensearch_dashboards.yml > opensearch_dashboards.yml.t
mv opensearch_dashboards.yml{.t,}

# READ NEW CONTENT 

cat config\opensearch_dashboards.yml

# NEW CONTENT LOOKS FINE, CLOSE SESSION

exit

# RUN IMAGE, AGAIN

podman run -it opensearchproject/opensearch-dashboards:1.2.0 /bin/bash

# READ CONTENT AGAIN

cat config\opensearch_dashboards.yml

# OLD CONTENT SHOWS UP

What am I missing? I thought I could update the image, but it doesn't work. Everytime the replace works, it goes up in flames. I'm new to containers and I feel stuck.

Upvotes: 0

Views: 928

Answers (1)

larsks
larsks

Reputation: 311645

Making changes in a container doesn't update the underlying image. A container has an ephemeral filesystem that only exists for the lifetime of the container -- when the container exits, the filesystem is gone.

Images are effectively read-only. If you want to make changes to the image, create a new one using an appropriate Dockerfile. You would probably start with something like:

FROM opensearchproject/opensearch-dashboards:1.2.0

...

Where you would replace ... with appropriate RUN or COPY commands to modify the image to meet your needs.

Upvotes: 1

Related Questions