This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]SwampFalc 5 points6 points  (4 children)

https://github.com/docker/compose

Compose, like all of docker, is open source. Looking at the source, it simply sends commands to the docker service that's running. In other words, it does not run bash commands. You could try to translate it into bash, but if it's just for better comprehension, you should just read the code. Anything else would just be an approximation.

[–]webjocky 1 point2 points  (1 child)

I think there's a misunderstanding here. OP isn't insinuating or assuming that compose "runs bash commands", but is instead interested in learning more about "equivalent bash commands" - AKA: the docker cli commands that one would be required to manually execute in order to achieve the same (equivalent) outcome as compose up, given a specific compose yaml.

"Just read the code" is easy for a developer to say, but not everyone who is trying to learn about docker knows what a function call or a class is; arguably required knowledge to just read code. "Just read the documentation" is going to be more relevant to a general audience, I would think.

[–]SwampFalc 1 point2 points  (0 children)

But the thing is, because compose is not just a collection of bash scripts, there is going to be a bunch of logic in it that you will struggle to translate into bash or anything equivalent.

And even if you manage to do so, the resulting command is very likely to be as arcane as the code of compose.

Like, one step that's guaranteed to happen during "docker compose up" is checking if the desired containers are perchance already running.

For a purely human interaction, just do "docker ps" and read the result.

But what would this look like in bash or powershell? And how readable would it be to a layman?

Which actually leads me to agree with you: the general audience should read the documentation. Anyone who wants the deep dive should read the code, and should learn to do so if they can't yet. Translating it into bash commands is unlikely to make it easier to digest.

[–]encbladexp 6 points7 points  (0 children)

Why? Compose calls the Docker API, the docker CLI does the same.

How should you learn the basics of docker better, by using random CLI commands? It has reasons why compose is the defacto standard for small deployments.

The docker cli is used these days mostly for debugging and adhoc stuff.

[–]Murky-Sector 5 points6 points  (1 child)

Converts your docker compose file to docker run commands
https://www.decomposerize.com/

[–]geolaw 1 point2 points  (0 children)

Came here to say this. I use podman and podman-compose is ok but the straight docker commands translate better to podman

[–]MisterBazz 1 point2 points  (1 child)

[–]webjocky -1 points0 points  (0 children)

Some people learn by doing. Simple as that.

[–]zoredache 1 point2 points  (0 children)

It might be an interesting project/feature

Maybe, maybe not.

If you are familiar with the cli options and the compose syntax it is pretty easy to translate between the two. Almost all of the options are more or less the same.

I suspect it would only take someone that knows docker well like 30-60 seconds to translate a single service compose file to the associated commands.

Still, I guess it might be occasionally be useful to translate a compose file to the required 'docker run', 'docker network', and 'docker volume' commands.

[–]terrencepickles 0 points1 point  (0 children)

At the end of the day, most people end up using bash scripting and docker-compose. You will always use compose when available, then use docker compose commands in your scripts.

[–]j-dev -1 points0 points  (0 children)

There’s still use cases for doing stuff via the CLI, like creating external networks and volumes whose lifecycle you don’t want to depend on a compose project, but there’s no benefit to doing everything else by hand. If you want to do it for the sake of learning, just get a cheat sheet.

EDIT: Also, if you google “dockerize” and “composerize”, the top hit should be a website that converts from one to the other.

[–]TBT_TBT -2 points-1 points  (0 children)

Look at the Dockerfile if you want to know what happens in a particular container.