postfwd - docker support [devel]
Author: jpk
Description: postfwd docker support
Keywords: postfwd, postfwd usage, postfwd manual, postfwd docker, docker, postfix, policy, policy delegation, firewall, postfix acl, postfix acls, pfwpolicy, postfw, restrictions, IT-Security, IT-Consulting, Jan, Peter, Kessler

## postfwd docker support [devel]

To run postfwd in a docker container you will need to access the development aka testing branch (at least version 1.36-devel2). You can use the pre-built image "postfwd/postfwd:testing" from DockerHub or download the postfwd distibution and build the image by yourself.

### Quicknav

- Using a pre-built image
  - docker
  - docker-compose
- Building your own image
  - get postfwd docker files
  - docker
  - docker-compose

### Using a pre-built image

#### a.) docker

- Get the image:

      docker pull postfwd/postfwd:testing

- Execute a container based on that image:

      docker run -v /path/to/ruleset:/etc/postfwd/postfwd.cf:ro -it postfwd/postfwd:testing

#### b.) docker-compose

- Create docker-compose.yml:

      version: '2'

      services:
        postfwd-testing:
          image: postfwd/postfwd:testing
          restart: always
          ports:
            # Modify interface and port below if required!
            - 127.0.0.1:10040:10040
          volumes:
            # Do not forget to create your ruleset an change /path/to/ruleset below!
            - /path/to/ruleset:/etc/postfwd/postfwd.cf:ro

- Execute the container:

      docker-compose up

### Building your own image

#### Get the postfwd docker files

The files "Dockerfile" and "docker-compose.yml" which were used to build the images at DockerHub can be found within the "docker"-subfolder of the postfwd distribution. You can find it at:

- GitHub:

      git clone https://github.com/postfwd/postfwd --branch testing --single-branch postfwd

- postfwd.org/DEVEL:

      wget https://postfwd.org/DEVEL/postfwd-latest.tar.gz && gzip -dc postfwd-latest.tar.gz | tar -xf - && rm postfwd-latest.tar.gz

#### a.) docker

- Edit the Dockerfile and build the image:

      docker build --no-cache --pull -t postfwd:testing .

- Execute a container based on that image:

      docker run -v /path/to/ruleset:/etc/postfwd/postfwd.cf:ro -it postfwd:testing

#### b.) docker-compose

- Edit the Dockerfile and the docker-compose.yml file and build the image:

      docker-compose build --no-cache --pull

- Execute the container:

      docker-compose up