Runlike: Given an existing Docker container, prints the command line to run it
github.com
github.com
I tried to persuade the docker maintainers that this was a good idea at some point, but the issue got closed in the end.
https://gist.github.com/efrecon/8ce9c75d518b6eb863f667442d7b...
https://github.com/lavie/runlike#not-yet-supported-run-optio...
I never run docker commands by itself unless it’s really simple. Simply whip up a docker compose file and aliasing compose works pretty well for me.
As an aside, the way Python code works feels really weird to me (even though I’ve done a bit of python). In particular, I find env to be odd. In this case you already need python installed (using pip to install this) or you need to run it as a container (which may or may not have significant overhead depending on how it was built). I’d suggest a compiled binary installed via a package manager for a command line tool. Had it been that, I may not have noticed.
I’m curious if other HN readers feel differently?
What overhead are you referring to? It runs, prints the cmdline and exits.
Edit: I’ve gone back and looked at the dockerfile. The base image is Ubuntu, so the docker image is heavy. I fetched the indicated image from Dockerhub and it's 228.13 MB. Most of the command line tools in my toolbox are measured in K not in hundreds of MB.
Personally I'd be inclined to install it via pipx.
If it would be a website where I paste the docker inspect output that would be the best.
that flag went away quite a while ago, I'd guess somewhere in the 1.20 versions
The devil is in the details, though. What do you do with files that were created in the container but aren't part of the a volume? A simple solution would be to throw them all away and start fresh, but then the "upgrade" command would only be able to work correctly for a subset of containers where throwing away previous files would be OK. If that were the case, I think "replace" would be a better command name than "upgrade" since you're effectively, if not literally, replacing the container.
Any other approach where you keep the files in from the old container files would lead to all sorts of corner cases or odd behavior. What if the upgraded image has moved where files are stored? What if the upgraded image's configuration is incompatible with the previous image's version?
It is very easy to do manually unless the command to start the container is lost, at that point a tool like the one being discussed becomes handy.
runlike -p runlike
This looks like a pretty neat tool, but when I'm spinning anything up non-trivial I usually just write docker-compose files so I'm not sure what use case I would have for it personally.
I try to use at least docker-compose.yaml for nearly everything. This is a nice tool for other times, without the hassle of other options.
There's your shell history, combined with fzf this helps recall previously run commands. You can search for something like "docker redis" and find it in a few key strokes.
If the container got spawned by something else then I think that's reaching for "beyond-the-edge" edge cases. I've been using Docker since 2014 and worked with dozens of companies (contract work) related to using Docker and this scenario has happened 0 times where I wanted to be able to replicate the flags used to spawn a container but couldn't find the command. Nearly every container is spawned from using Docker Compose or it exists in your shell's history.
I agree you should never be in this situation (this place is an absolute nightmare), but here I am!
I've run into similar history management problems with `screen`.
HISTTIMEFORMAT=“%F %T $(logname) $(pwd) “
if [ ! -d $HOME/.history ]
then mkdir -p $HOME/.history
fi
PROMPT_COMMAND=‘echo “$(history 1)” >> $HOME/.history/$(date “+%F”)
fi
export PROMPT_COMMANDI suppose adding `readonly PROMPT_COMMAND` would be a good idea so no one overwrites it, but most people wouldn’t even think to look for it.
I don’t think this would do much for handling screen history, though.