Comments (6)
interestingly my own company does something similar. We have a program that you can basically use in place of docker-compose and you're able to do it from any directory and it will work. So I made setting the docker-compose command configurable. You just need to do have:
commandTemplates:
dockerCompose: 'custom-compose'
In your case it would be dockerCompose: 'docker-compose -f foo.yml
That satisfies my use case where we only ever really need to be in a single context, but it seems like you would need to change your 'dockerCompose' config value depending on your current context. I think making it a command-line arg makes sense, though I'm not sure what the best approach would be.
One approach would be to pass in the entire docker-compose command like
ld --dc "docker-compose -f foo.yml -f bar.yml"
This is the most flexible because it supports adding pretty much anything you want into that command, and allows as many -f arguments as you want. It's also simply because it will just replace the default docker-compose command from your config. But it might be annoying to have to write 'docker-compose' all the time when you're not somebody who has their own custom docker-compose program.
So maybe it should be that if you supply -f flags, each one is just going to be tacked onto whatever the docker-compose command is from the config. And then we'll wait and see if anybody needs more flexibility than that.
What are your thoughts?
from lazydocker.
Our use case is always just one docker-compose file at a time, I didn't actually realise you could pass multiple! So for me ld -f foo.yml
would be perfect as opposed to ld --dc "docker compose -f foo.yml"
, and for the multiple files case multiple -f
flags definitely sounds nicer if that works. I guess the other question would be whether there's any other docker-compose
flags others would want to pass through though, since at some point it might be preferable to use the --dc
approach than proxy multiple flags through.
BTW I'd be interested in tackling this as a learning exercise if it's not a burning issue for others :)
from lazydocker.
If you wanna have a crack be my guest :)
It turns out that the standard 'flag' package doesn't support using the same flag multiple times, but flaggy https://github.com/integrii/flaggy does, and from the looks of it it's not too hard to set up. We only parse a couple flags so far, and it's all in main.go
, so I don't think it would be too hard to use that package. Then we'd need to pass in a dockerComposeFiles array of strings into config.NewAppConfig()
(in the same way we currently pass in debuggingFlag
) and then do something like this:
if len(dockerComposeFiles) > 0 {
userConfig.CommandTemplates.DockerCompose += "-f " + strings.Join(dockerComposeFiles, " -f ")
}
How does that sound difficulty wise? If it's a bit daunting I'm happy to take care of the flaggy package part and leave you to actually dealing with the arg :)
from lazydocker.
Thanks for the pointers! Sounds like it should be doable, I’ll try to make a PR to move the existing code to Flaggy and then a separate one to add the multiple -f flags for this. I’m a newbie with Go so the PR might need a bit of feedback, and I’ll reach out on the Slack or here if I’m having trouble. I’ll see what I can do though! :)
from lazydocker.
FWIW, in my company we have a microservices based app and we use multiple docker-compose files for the various services. We have a local configuration file a dev can edit to decide which services they want to have running. You can dev/test parts of our app without having everything running and this just saves CPU and RAM. We have a shell script we use which reads the config file and then builds the list of docker-compose files to use. So it is just a simple script that mirrors the common docker-compose commands except it builds the -f option.
I was thinking maybe lazydocker could have an optional -f option that it would use to pass along to docker-compose? We could then just add an option to our shell script to run lazydocker with this option?
from lazydocker.
@markphip I think we have the same use case :) Just you need the multiple -f commands which validates that decision too.
from lazydocker.
Related Issues (20)
- Make it clear that cheetsheets are auto-generated HOT 2
- Check cheatsheet is up to date in CI HOT 2
- Use "docker compose" instead of "docker-compose" HOT 1
- Add installation possibility with winget
- lazydocker running in git-bash via Windows Terminal, but not inside standalone git-bash
- 0.19.0 tag, but no release HOT 2
- Allow sorting by column in list panels HOT 8
- Hotkey for entering a running container's shell HOT 2
- Update latest release changelog HOT 1
- after upgrading to v0.19 i cannot see all containers running on current host HOT 1
- No logs from random containers after updating to 0.19.0 HOT 5
- Change selected background color like lazygit
- Allow tagging, pushing, and pulling images HOT 20
- [Bug] macOS Catalina: illegal option HOT 5
- brew install lazydocker don't work HOT 9
- [BUG] Lazydocker displaying wrong container name HOT 9
- Allow changing the default screen mode HOT 3
- Selected service automatically moves when there are multiple services with the same config HOT 3
- Clear logs HOT 11
- Shorten container status and health to 1 character HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lazydocker.