Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sadok-f/docker-secrets
Simple PHP library to read docker secrets.
https://github.com/sadok-f/docker-secrets
docker docker-secret docker-secrets php php-library swarm
Last synced: 24 days ago
JSON representation
Simple PHP library to read docker secrets.
- Host: GitHub
- URL: https://github.com/sadok-f/docker-secrets
- Owner: sadok-f
- License: mit
- Created: 2017-09-29T15:48:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T14:07:37.000Z (over 6 years ago)
- Last Synced: 2024-09-24T21:56:18.560Z (about 1 month ago)
- Topics: docker, docker-secret, docker-secrets, php, php-library, swarm
- Language: PHP
- Size: 22.5 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Secrets
A simple PHP library to read [docker secrets](https://docs.docker.com/engine/swarm/secrets/) from a Swarm cluster.
# Installation
```bash
composer require sadok-f/docker-secrets
```# Usage
### Read All
```php
$dockerSecrets = new DockerSecrets\Reader\SecretsReader();
$allSecrets = $dockerSecrets->readAll();
```
return:
```
Array
(
[my_secret_data_1] => testSecretDataContent1
[my_secret_data_2] => testSecretDataContent2
)
```### Read a single secret
```php
$dockerSecrets = new DockerSecrets\Reader\SecretsReader();
$dockerSecrets->read('my_secret');
```### Custom Location
The default location for secrets folder is to `/run/secrets/` in Linux containers.
if you're using Docker 17.06 and higher with custom location you can use the library like this example:```php
$dockerSecrets = new DockerSecrets\Reader\SecretsReader('/var/myCustomLocation');
$dockerSecrets->read('my_secret');
```### Read secrets in Windows containers
```php
$dockerSecrets = new DockerSecrets\Reader\SecretsReader('C:\ProgramData\Docker\secrets');
$dockerSecrets->read('my_secret');
```# PHPUnit
```bash
./vendor/bin/phpunit
```