3 ms·
What if I used an bare image, installed some stuff and can't remember what all I did to get it in a usable state for my application. I wish it could automatica
by brcmthrowaway 2y ago
What if I used an bare image, installed some stuff and can't remember what all I did to get it in a usable state for my application.
I wish it could automatically create a Dockerfile for me.
- wahnfrieden 2y agoyou can but it's not recommended because it's basically impossible to audit changes made and is unrepeatable https://stackoverflow.com/a/46917993/89373 https://stackoverflow.com/a/46917993/89373
- ptrrrrrrppr 2y ago``` tail .zsh_history > setup.sh echo COPY setup.sh >> Dockerfile echo RUN ./setup.sh >> Dockerfile ```
- dijksterhuis 2y agoSee ‘docker container commit’ [0] > Create a new image from a [running] container's changes You might then be able to run ‘docker image history’ [1] to get the changes, which you might be able to write into your own Dockerfile [2] but I’ve never tested this workflow because the best practice is just to write a Dockerfile first The tool (docker) was designed in a specific way, learn how to use the tool’s workflow instead of wishing for a different workflow and you’ll have a much easier time. [0]: https://docs.docker.com/reference/cli/docker/container/commit/ https://docs.docker.com/reference/cli/docker/container/commi... [1]: https://docs.docker.com/reference/cli/docker/image/history/ https://docs.docker.com/reference/cli/docker/image/history/ [2]: can’t remember how docker tracks internal container file system changes and whether the history command will pick them up Edit — see sibling comment https://news.ycombinator.com/item?id=41371867 https://news.ycombinator.com/item?id=41371867 — basically… learn to build a dockerfile (they’re very simple and easy once you know how).