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)
- Update version execution error: could not determine host context "default" does not exist HOT 12
- Docker image missing 1.20-3.15 HOT 4
- Changed DOCKERFILE with existing hub image
- After running lazydocker, docker completely breaks and it starts to require root permissions HOT 2
- Cannot install on Debian 5.10.197-1 via curl .sh HOT 2
- Custom Colors/Theme Config
- Possibility to configure different servers to manage the Dockers and have then split on "tabs" HOT 4
- Request: View only mode
- Enhance Image Section with Active Use Indicator HOT 2
- Connecting to remote docker host over ssh is broken
- XDG base directory specification is not described in the config docs
- Config options for side panel visibility / size HOT 1
- Rounded Corners
- can't install following README instructions HOT 1
- Installing on arch linux using yay fails HOT 3
- Can I pass a flag to set the Project Name to something ?
- Cannot proceed until docker gives us more information about the container. Please retry in a few moments.
- Move the panel with number like lazygit
- Container log colors
- Selectable Logs/Stats/Env/Config/Top HOT 1
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.