manifoldco/torus-cli

Unable to set preferences on Docker container

radmen opened this issue ยท 4 comments

I've quite an odd situation. CLI is unable to set preferences when running on Docker container.

$ docker run -it --rm desmart/rancher-deploy bash
bash-4.3# torus prefs set core.hints false
Failed to save preferences.
open : no such file or directory
bash-4.3# torus -v
CLI         0.30.0
Daemon      0.30.0
Registry    0.25.0

I'm unable to locate the error in source code.

I've tried running this simple code on the container (based on https://github.com/manifoldco/torus-cli/blob/master/prefs/prefs.go#L122):

package main

import "fmt"
import "os/user"
import "path"

const (
	rcFilename        = ".torusrc"
)

func main() {
	u, err := user.Current()
	if err != nil {
		fmt.Printf("error: %+v", err)
	}
	fmt.Printf("dir: %+v", path.Join(u.HomeDir, rcFilename))
}

It returns path correctly. I'm guessing that this also works correctly on the CLI.
Yet, for some reason, it fails to get the proper path to the config file.

Thanks for reporting the bug, I'll take a gander today to see if I can figure out what happened!

Could you give me some information about the image you're building? Is it alpine based, ubuntu, etc? Are you running as the root user, or another user?

It's possible for some reason torus can't access the $HOME directory.

In my case it was based on alpine.

Here's the minimum dockerfile:

FROM alpine:latest

RUN apk add --no-cache curl \
	&& curl -Lso torus-install.sh https://raw.githubusercontent.com/radmen/docker-build-scripts/master/scripts/alpine/torus-cli \
	&& chmod +x torus-install.sh \
	&& ./torus-install.sh

Install script basically fetches the latest cli zip file.
I've tried to run same steps on ubuntu image. Results were the same.

In both cases CLI was run as a root.

Works :) thank you!