Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Maybe using docker run .... bash -c 'apt update && apt upgrade && bash' is what you're looking for. Or if you are building the docker image from scratch you could add a script in some path of the docker image and run it with docker run .... /path/to/scipt Commented Jul 20, 2023 at 10:08
  • I cannot test for now the command above but afaik you should use bash (or any other command that does not exit) to avoid the container exits after the upgrade. Commented Jul 20, 2023 at 10:14
  • Why not just make images (e.g. with docker export mycontainerid | docker import - myimagename) with the base distro plus all updates and extra packages you need, then use that for your disposable containers? If you don't auto-delete a container with --rm, you can export it (then manually delete it after exporting it). You could even add a script which does a full, no-questions asked upgrade & install extra packages (with commands appropriate for the base distro, fedora or ubuntu or whatever) in case you need to update it again, and then make a new image from the updated container. Commented Jul 21, 2023 at 8:12
  • this is a quick-and-dirty way of manually building a container image without using docker build or needing a yaml dockerfile or whatever. Alternatively, don't --rm the container, and just use docker start to re-run it when you need it. That would only allow you to have one instance running at a time, though. Commented Jul 21, 2023 at 8:15