Giter Club home page Giter Club logo

webhook-docker's Introduction

CD Status Last Commit Pull Requests Repo Size Image Size Pulls Version License

A light image of adnanh's webhook which is able to access the Docker host and control containers. This image is based upon TheCatLady's webhook docker image. In addition to some minor tweaks this image has access to the docker host and therefore is able to execute Docker commands on the host. This is possible by exposing the docker socket and adding packets for docker compose and the docker cli.

Table of Contents

Security Concerns

In order to run docker commands inside the container and actually execute them on the docker host, the docker socket of the host needs to be exposed. While this allows to execute docker commands (e. g. for a CI/CD workflow) triggered by a webhook, it also poses a security risk. The risk involves that a container which has access to the docker socket may be able to get root access to the host. In order to lessen this security threat a Docker Socket Proxy can be used (e. g. Tecnativa's Docker Socket Proxy).

Also, if you further want to inform yourself about the advantages and risks of executing docker commands inside a docker conatainer and access the docker host via the Docker socket, take a look for example at this post from Jérôme Petazzoni or this post from Tom Gregory.

How to use

Docker images are available from Docker Hub and GitHub Container Registry (GHCR).

Docker Compose (example)

Add the following volume and service definitions to a docker-compose.yml file:

services:
  webhook:
    image: heg0dmsk/webhook-docker
    container_name: webhook
    command: -verbose -hooks=hooks.json -hotreload
        environment:
      - TZ=Europe/Berlin #optional
    volumes:
      - /path/to/appdata/config:/config:ro
      # exposing the docker socket, needed to access the docker host
      - /var/run/docker.sock:/var/run/docker.sock 
    ports:
      - 9000:9000
    restart: always

Then, run the following command from the directory containing your docker-compose.yml file:

docker-compose up -d

Updating

The process to update the container when a new image is available is dependent on how you set it up initially. If you initially used Docker Compose, run the following commands from the directory containing your docker-compose.yml file:

# Pull latest version of the images specified in the docker-compose.yml file
docker-compose pull 

# Redeploy
docker-compose up -d

# Remove old dangling Images
docker image prune

Parameters

The container image is configured using the following parameters passed at runtime:

Parameter Symbol Example Description
Volume -v /path/to/appdata/config:/config:ro Container data directory (mounted as read-only); your JSON/YAML hook definition file should be placed in this folder
(Replace /path/to/appdata/config with the desired path on your host)
Volume -v /var/run/docker.sock:/var/run/docker.sock Exposing the docker socket, needed to access the docker host
Port -p 9000:9000 Expose port 9000
(Necessary unless only accessing webhook via other containers in the same Docker network)
Restart Policy --restart recommended always Container restart policy
Command -verbose -hooks=/config/hooks.json -hotreload webhook parameters; replace hooks.json with the name of your JSON/YAML hook definition file, and add/modify/remove arguments to suit your needs
(Can omit if using this exact configuration; otherwise, all parameters must be specified, not just those modified)
environment -e TZ=Europe/Berlin Specifcies timezone of the container, Look up timezones here

Configuring Hooks

See adnanh/webhook for documentation on how to define hooks.

webhook-docker's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar heg0dmsk avatar onedr0p avatar renovate[bot] avatar thecatlady avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.