Skip to content

clementmouchet/op-connect-secret-driver

Repository files navigation

op-connect-secret-driver

A Docker Secret driver for 1Password Connect

This Docker Secret driver plugin integrates with 1Password Connect server to securely manage secrets in Docker Swarm.

Requirements

Note: Unix socket creation is only supported on Linux and FreeBSD due to limitations in the "go-plugins-helpers" package.

Configuration

Connection to 1Password Connect

The SDK requires these environment variables to connect to 1Password Connect:

  • OP_CONNECT_HOST: URL of your 1Password Connect server
  • OP_CONNECT_TOKEN: Your 1Password Connect authentication token

Set them as Docker plugin configuration

docker plugin set op-connect-secret-driver:latest OP_CONNECT_HOST=http://localhost:17450 
docker plugin set op-connect-secret-driver:latest OP_CONNECT_TOKEN=your-1password-connect-token

Docker Secret Driver Configuration

The plugin supports two ways to reference secrets:

  1. Individual fields using vault, item, and optional field provided as secret labels
  2. 1Password URL format using the ref as secret label in the format op://vault/item/field (that you can copy from 1Password directly)

Notes:

  • The field parameter is optional and defaults to "password" if not specified
  • The plugin can retrieve both field values and file contents from 1Password items
  • All configuration is done through labels

Example Docker Compose configurations:

# Option 1: Using individual fields
secrets:
  db_password:
    driver: op-connect-secret-driver
    labels:
      vault: "your-vault-uuid-or-name"             # Required: Vault UUID or name
      item: "your-item-uuid-or-name"               # Required: Item UUID or name
      field: "password"                            # Optional: Defaults to "password"

# Option 2: Using 1Password URL reference
secrets:
  db_password:
    driver: op-connect-secret-driver
    labels:
      ref: "op://vault-name/item-name/field-name"  # Required: 1Password URL format

Installation from Docker Hub

The CI pipeline automatically builds and publishes the plugin to Docker Hub. You can use this command to install the plugin:

linux/amd64

docker plugin install clementmouchet/op-connect-secret-driver:linux-amd64 \
--grant-all-permissions \
--alias op-connect-secret-driver \
--disable

linux/arm64

docker plugin install clementmouchet/op-connect-secret-driver:linux-arm64 \
--grant-all-permissions \
--alias op-connect-secret-driver \
--disable

Build

You can also develop, build your own and install it locally.

Recommended: Docker Build

docker compose build op-connect-secret-driver
docker compose up -d op-connect-secret-driver
docker compose cp op-connect-secret-driver:/op-connect-secret-driver plugin/rootfs/op-connect-secret-driver
docker compose stop op-connect-secret-driver && docker compose rm -f op-connect-secret-driver

Alternative: Local Build

go build -o plugin/rootfs/op-connect-secret-driver

Installation of local build

There's an install.sh script for this.

./install.sh

Manual Installation

  1. Create the plugin:
docker plugin create op-connect-secret-driver plugin
  1. Configure the plugin:
docker plugin set op-connect-secret-driver:latest OP_CONNECT_HOST=http://localhost:17450 
docker plugin set op-connect-secret-driver:latest OP_CONNECT_TOKEN=your-1password-connect-token
  1. Start 1Password Connect services:
docker compose up op-connect-api
  1. Enable the plugin:
docker plugin enable op-connect-secret-driver:latest

Modifying Plugin

To modify plugin settings, first disable:

docker plugin disable op-connect-secret-driver:latest

To modify plugin code, first remove it, build it and start the installation process again.:

docker plugin remove op-connect-secret-driver:latest

Troubleshooting

  1. Verify plugin status:
docker plugin ls
  1. Check plugin logs (syslog) or inspect it:
docker plugin inspect op-connect-secret-driver:latest
  1. Verify configuration:
docker plugin inspect op-connect-secret-driver:latest -f "{{ .Settings.Env }}"
  1. Ensure 1Password Connect server is accessible at the configured host