1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-23 01:39:27 +02:00
dockerfiles/vault/README.md

63 lines
1.6 KiB
Markdown
Raw Normal View History

2015-07-18 09:30:30 +02:00
vault
=====
2015-07-18 09:44:59 +02:00
![](https://badge.imagelayers.io/vimagick/vault:latest.svg)
2015-07-18 09:30:30 +02:00
[`Vault`][1] is a tool for securely accessing secrets. A secret is anything
that you want to tightly control access to, such as API keys, passwords,
certificates, and more. Vault provides a unified interface to any secret, while
providing tight access control and recording a detailed audit log.
2015-07-18 09:44:59 +02:00
## docker-compose.yml
2017-12-12 11:29:22 +02:00
```yaml
2015-07-18 09:44:59 +02:00
vault:
image: vimagick/vault
ports:
- "8200:8200"
2015-07-18 10:24:47 +02:00
volumes:
2017-12-12 11:29:22 +02:00
- ./data/etc:/etc/vault
- ./data/var:/var/lib/vault
- ./data/log:/var/log/vault
2015-07-18 12:12:21 +02:00
cap_add:
- IPC_LOCK
2015-07-18 09:44:59 +02:00
restart: always
```
2015-07-18 10:32:56 +02:00
> Please distribute `vault.crt` to clients.
2015-07-18 10:24:47 +02:00
2015-07-18 09:44:59 +02:00
## server
2017-12-12 11:29:22 +02:00
```bash
2015-07-18 09:44:59 +02:00
$ cd ~/fig/vault
2017-12-12 11:29:22 +02:00
$ mkdir data
$ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout data/etc/vault.key -out data/etc/vault.crt
2015-07-18 09:44:59 +02:00
$ docker-compose up -d
$ docker cp vault_vault_1:/usr/bin/vault /usr/local/bin/
2015-07-18 11:08:30 +02:00
$ docker exec -it vault_vault_1 sh
>>> cd /etc/vault
2017-12-12 11:29:22 +02:00
>>> vault init -key-shares=5 -key-threshold=3 | tee vault.secret
2015-07-18 11:08:30 +02:00
>>> exit
2017-12-12 11:29:22 +02:00
$ docker run --rm --volumes-from vault_vault_1 -v `pwd`:/backup alpine tar cvzf /backup/vault.tgz /etc/vault /var/lib/vault /var/log/vault
2015-07-18 09:44:59 +02:00
```
2015-07-18 11:08:30 +02:00
> Split `vault.secret`, keep them a secret.
2015-07-18 09:44:59 +02:00
## client
2017-12-12 11:29:22 +02:00
```bash
2015-07-18 11:08:30 +02:00
$ export VAULT_ADDR='https://server:8200'
2017-12-12 11:29:22 +02:00
$ export VAULT_SKIP_VERIFY=0
$ cp ~/fig/vault/data/etc/vault.crt /etc/ssl/certs/vault.pem
2015-07-18 11:08:30 +02:00
$ update-ca-certificates
2015-07-18 09:44:59 +02:00
$ vault status
2015-07-18 11:08:30 +02:00
$ vault unseal && vault unseal && vault unseal
2015-07-18 10:03:34 +02:00
$ vault auth
2017-12-12 11:29:22 +02:00
$ vault audit-enable file file_path=/var/log/vault/audit.log
2015-07-18 10:03:34 +02:00
$ vault write secret/name key=value
$ vault read secret/name
2015-07-18 09:44:59 +02:00
$ vault seal
```
2015-07-18 09:30:30 +02:00
[1]: https://www.vaultproject.io/