Making permanent changes to a container

Hello,
Can permanent changes be made in a container? For example, install a program in the container and after turning the container off and on, that program is not deleted.

Cheers.

Yes you can… but only in the image (see the Dockerfile) but never ever in a container. (Sorry for the bad joke)

You can code the installation in a Dockerfile or… everytime you start the container with some automation (I think here to a entrypoint.sh script fired everytime the container is created).

1 Like

Hello,
Thank you so much for your reply.
I’ve already seen something like RUN docker-php-ext-install mysqli pdo pdo_mysql in the Dockerfile. Is it not possible to include this command in the YAML file?

Fast answer : no.

You have to do this in an image or as said everytime you run the container (not productive at all)

Hi,
Thanks again.
I think I can simulate it using the command command:

command: apt install docker-php-ext-install mysqli pdo pdo_mysql

By reading Compose file version 3 reference | Docker Docs, this is not, at all, the same thing.

Imagine the default command is, just “/bin/sh” so when I’ll run your container, “by default”, I’ll obtain a Linux console.

here, you’re overriding that “default command” and mention, nope, you should install a few things then … exit.

Unless I’m saying an error, just try your idea and tell us what happens then.

For me, you’ll never get a shell here (except your override once more the default command using CLI flags)