mirror of https://github.com/portainer/portainer
fix: docker-compose use custom config.json to access private images (#5058)
cherry-picking commit a6b289c9
.
Co-authored-by: Dmitry Salakhov <to@dimasalakhov.com>
pull/5080/head
parent
0ac6274712
commit
3641158daf
|
@ -76,7 +76,7 @@ func initDataStore(dataStorePath string, fileService portainer.FileService) port
|
||||||
}
|
}
|
||||||
|
|
||||||
func initComposeStackManager(assetsPath string, dataStorePath string, reverseTunnelService portainer.ReverseTunnelService, proxyManager *proxy.Manager) portainer.ComposeStackManager {
|
func initComposeStackManager(assetsPath string, dataStorePath string, reverseTunnelService portainer.ReverseTunnelService, proxyManager *proxy.Manager) portainer.ComposeStackManager {
|
||||||
composeWrapper := exec.NewComposeWrapper(assetsPath, proxyManager)
|
composeWrapper := exec.NewComposeWrapper(assetsPath, dataStorePath, proxyManager)
|
||||||
if composeWrapper != nil {
|
if composeWrapper != nil {
|
||||||
return composeWrapper
|
return composeWrapper
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,19 @@ import (
|
||||||
// ComposeWrapper is a wrapper for docker-compose binary
|
// ComposeWrapper is a wrapper for docker-compose binary
|
||||||
type ComposeWrapper struct {
|
type ComposeWrapper struct {
|
||||||
binaryPath string
|
binaryPath string
|
||||||
|
dataPath string
|
||||||
proxyManager *proxy.Manager
|
proxyManager *proxy.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewComposeWrapper returns a docker-compose wrapper if corresponding binary present, otherwise nil
|
// NewComposeWrapper returns a docker-compose wrapper if corresponding binary present, otherwise nil
|
||||||
func NewComposeWrapper(binaryPath string, proxyManager *proxy.Manager) *ComposeWrapper {
|
func NewComposeWrapper(binaryPath, dataPath string, proxyManager *proxy.Manager) *ComposeWrapper {
|
||||||
if !IsBinaryPresent(programPath(binaryPath, "docker-compose")) {
|
if !IsBinaryPresent(programPath(binaryPath, "docker-compose")) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ComposeWrapper{
|
return &ComposeWrapper{
|
||||||
binaryPath: binaryPath,
|
binaryPath: binaryPath,
|
||||||
|
dataPath: dataPath,
|
||||||
proxyManager: proxyManager,
|
proxyManager: proxyManager,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,8 @@ func (w *ComposeWrapper) command(command []string, stack *portainer.Stack, endpo
|
||||||
|
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
cmd := exec.Command(program, args...)
|
cmd := exec.Command(program, args...)
|
||||||
|
cmd.Env = os.Environ()
|
||||||
|
cmd.Env = append(cmd.Env, fmt.Sprintf("DOCKER_CONFIG=%s", w.dataPath))
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
|
|
|
@ -42,7 +42,7 @@ func Test_UpAndDown(t *testing.T) {
|
||||||
|
|
||||||
stack, endpoint := setup(t)
|
stack, endpoint := setup(t)
|
||||||
|
|
||||||
w := NewComposeWrapper("", nil)
|
w := NewComposeWrapper("", "", nil)
|
||||||
|
|
||||||
err := w.Up(stack, endpoint)
|
err := w.Up(stack, endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue