Skip to content

Commit

Permalink
Document Docker usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tangowithfoxtrot committed Feb 1, 2024
1 parent b96160b commit 84c7382
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions crates/bws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,45 @@ echo 'source <(/path/to/bws completions bash)' >> ~/.bashrc

For more detailed documentation, please refer to the
[Secrets Manager CLI help article](https://bitwarden.com/help/secrets-manager-cli/).

### Docker

You can also use the `bws` CLI with Docker:

<!-- TODO: remove the build step once the Docker image is published to the Docker Hub -->

```bash
# From the root of the repository, build the Docker image:
docker build -f crates/bws/Dockerfile --no-cache -t bitwarden/bws .

# Run with Docker:
docker run --rm -it bitwarden/bws --help
```

The Docker image is ran with a non-root user named `app`. If you need to pass your config file to
the container, you can use the `-v`/`--volume` flag to mount your local `.bws` directory to the
default location within the container:

```bash
docker run --rm -it -v "$HOME"/.bws:/home/app/.bws bitwarden/bws --help
```

Alternatively, you can use the `BWS_CONFIG_FILE` environment variable to specify the location of the
config file within the container:

```bash
docker run --rm -it -e BWS_CONFIG_FILE="/path/to/config/file" -v /path/to/config/file:"$BWS_CONFIG_FILE" bitwarden/bws --help
```

Or, more concisely:

```bash
# Set the BWS_CONFIG_FILE environment variable on your host
export BWS_CONFIG_FILE="/path/to/config/file"

# Pass the BWS_CONFIG_FILE environment variable to the container
docker run --rm -it -e BWS_CONFIG_FILE="$BWS_CONFIG_FILE" -v "$BWS_CONFIG_FILE":"$BWS_CONFIG_FILE" bitwarden/bws --help
```

Note that if you want to use identitcal config file paths on your host and in the container, the
parent directory must exist on both.

0 comments on commit 84c7382

Please sign in to comment.