Skip to content
anchor

GitHub Action

docker-context-create

v2 Latest version

docker-context-create

anchor

docker-context-create

Creates a docker context pointing to a remote docker engine using SSH authentication

Installation

Copy and paste the following snippet into your .yml file.

              

- name: docker-context-create

uses: ArwynFr/actions-docker-context@v2

Learn more about this action in ArwynFr/actions-docker-context

Choose a version

Github Action creating SSH Docker context

This action creates a docker context, allowing access to a remote docker engine over SSH from your workflows. By default, you must refer to the context by its name with the --context switch, or you can set use_context to true in order to set that new context as the current docker context.

Inputs

docker_host

Required. URL to the remote docker engine in format ssh://[email protected].

context_name

Required. Name of the remote context on the local docker client.

use_context

If set to true, the docker context will be set as the current docker context. Defaults to false.

ssh_cert

Public key of the SSH server, in known_hosts format. The public key is added to the current user's known_hosts file, and you can reuse previously added keys. Using a Github secret is recommended.

ssh_key

Private key of the SSH client. The key is stored using ssh-agent, so you can reuse an existing private key instead. Using a Github secret is recommended.

Example

on:
  push: [master]

jobs:
  publish:
    runs-on: ubuntu-latest
    name: 'Publish on the development server'
    steps:

    - uses: arwynfr/actions-docker-context@v2
      with:
        docker_host: 'ssh://[email protected]'
        context_name: 'dev-server'
        ssh_cert: ${{ secrets.SSH_CERT }}
        ssh_key: ${{ secrets.SSH_KEY }}

    - run: docker --context dev-server stack deploy --compose-file stack/docker-compose.yml my-stack