Use flyctl from container

Hi, I don’t want to install go and flyctl in my environment and use the dockerized version of flyctl. I have no problems running commands, even auth login is no problem. But how to I persist my credentials, which volume do I have to bind mount?

Idea would be to have an alias command named flyctl defined as ‘docker run -it Package flyctl · GitHub’, which would enable me to use flyctl as if it was installed locally.

thanks a lot in advance

That would be `~/.fly. From the install script:

flyctl_install="${FLYCTL_INSTALL:-$HOME/.fly}"

You can customize the location of the FLYCTL_INSTALL

Take note, if you’re mounting this directory, you basically have an install, just that the binary is not available in your PATH :slight_smile:

If you want to be sure to not even have the binary and just the state/config files:

docker run \
    --mount type=bind,src=/<host-folder>,dst=~/.fly \
    --mount type=volume,dst=~/.fly/bin/

Hey thanks a lot for your reply! Though I’m having two issues with it:

  1. you are not refering to the official docker image, do you? As the official one is based on scratch (flyctl/Dockerfile at master · superfly/flyctl · GitHub) it doesn’t seem to know something like a home directory.
  2. Docker tells me that I am not allowed to mountbind relative paths (~)

Nevertheless I appreciate your approach and am still optimistic to find a solution :slight_smile:
Any idea on how to fix those issues?

Ahh, I have an idea :slight_smile:

Try setting an env var for FLY_CONFIG_DIR
So you could do something like:

docker run \
    --mount type=bind,src=/<host-folder>,dst=/.config \
    --mount type=volume,dst=/.config/bin/ \
    -e FLY_CONFIG_DIR="/.config"

In theory, this should then persist the socket.

Haha, amazing! Thanks a lot - it works :slight_smile:

So I ended up with this alias entry in my .bash_aliases:

alias flyctl='docker run -it --rm --name flyctl --mount type=bind,src=/<HOST CONFIG FOLDER>,dst=/.config --mount type=volume,dst=/.config/bin/ -e FLY_CONFIG_DIR="/.config" ghcr.io/superfly/flyctl:latest'

works like a charm!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.