Scaleway logo
Documentation

Using the CLI with Docker

The CLI documentation pages are currently under construction

The content is up to date. We're making improvements to the site over the next few weeks for a better experience.

The CLI can be used in Docker without any problem.

Basic usage

In order to use it you must mount the scaleway configuration file:

TerminalCode
docker run -it --rm -v $HOME/.config/scw:/root/.config/scw scaleway/cli:v2.26.0

If you want to use scw instead of docker run you can add the following in your ~/.bashrc:

TerminalCode
scw() { docker run -it --rm -v $HOME/.config/scw:/root/.config/scw scaleway/cli:v2.26.0 "$@" } export -f scw

Or if you use ZSH, add the following in your ~/.zshrc:

TerminalCode
scw() { docker run -it --rm -v $HOME/.config/scw:/root/.config/scw scaleway/cli:v2.26.0 $@ }

Use your ssh-key

In order to use your ssh-key you must mount your .ssh folder

TerminalCode
docker run -it --rm -v $HOME/.config/scw:/root/.config/scw -v $HOME/.ssh:/root/.ssh scaleway/cli:v2.26.0 $@

You can then ensure that your ssh key is present in your Scaleway account

TerminalCode
scw iam ssh-key init

Autocompletion

You can still use autocompletion while running the CLI in Docker, you just need to modify script generated by the CLI. For instance, scw autocomplete script shell=bash will return:

TerminalCode
_scw() { _get_comp_words_by_ref -n = cword words output=$(scw autocomplete complete bash -- "$COMP_LINE" "$cword" "${words[@]}") COMPREPLY=($output) # apply compopt option and ignore failure for older bash versions [[ $COMPREPLY == *= ]] && compopt -o nospace 2> /dev/null || true return } complete -F _scw scw

And in your ~/.bashrc you can add:

TerminalCode
scw() { docker run -it --rm -v $HOME/.config/scw:/root/.config/scw scaleway/cli:v2.26.0 "$@" } export -f scw _scw() { _get_comp_words_by_ref -n = cword words output=$(docker run -i --rm -v $HOME/.config/scw:/root/.config/scw scaleway/cli:v2.26.0 autocomplete complete bash -- "$COMP_LINE" "$cword" "${words[@]}") COMPREPLY=($output) # apply compopt option and ignore failure for older bash versions [[ $COMPREPLY == *= ]] && compopt -o nospace 2> /dev/null || true return } complete -F _scw scw

The trick is to remove the -t when using docker inside the completion function.

Using the CLI with Podman

If running with Podman and SELinux in enforcing mode, one must use the option when mounting the configuration file.
For instance:

TerminalCode
podman run -it --rm -v $HOME/.config/scw:/root/.config/scw:Z scaleway/cli:v2.26.0