Faraday Community Edition Installation Guide with Docker¶
This guide provides step-by-step instructions for installing the Community Version of Faraday using Docker. The instructions cover both running Faraday as a standalone container and as a service. Additionally, environment variables and volumes for configuration are explained in detail.
Configuration¶
This image can be run as a service or as a standalone container. Both run Faraday Server without PostgreSQL. You will note that we have created /faraday-storage
and /faraday-config
volumes (for mounting your storage and configuration). We have also created environment variables for Faraday configuration in case you don't mount a config volume. We will get more in detail of these volumes and environment variables:
Example:
Running Faraday as a standalone container
docker run \
...
-v /path/to/my_doc_folder:/faraday-license \
-v /path/to/my_storage_folder:/faraday-storage \
-v /path/to/my_config_folder:/faraday-config
...
faradaysec/faraday:4.6.2
Running Faraday as a service
vim docker-compose.yml
version: '4.02'
services:
...
volumes:
- /path/to/{my_config_folder}:/home/faraday/.faraday
...
We will get more in details about this configuration below.
Environment Variables¶
In case you don't have a configuration file you'll need to set some environment variables. These come with default values so you'll need to customize some or all of them depending on your installation config.
PGSQL_HOST=172.2.0.1 # PostgreSQL server host.
PGSQL_USER=faraday_postgresql # PostgreSQL user
PGSQL_PASSWD=mypgsqlpassword # PostgreSQL user's password.
PGSQL_DBNAME=faraday # Faraday's database name
Running Faraday¶
Now that we have learnt about the volumes and the environment variables above, let's run Faraday assuming we want to connect into PostgreSQL's address 192.168.20.29 and that we have located Faraday's config folder in its default location: ~/.faraday
As a standalone container¶
Run the following command specifying the correct information:
With environment variables
docker run \
-v ~/.faraday/doc:/faraday-license \
-v ~/.faraday/storage:/faraday-storage \
-p 5985:5985 \
-e PGSQL_HOST='192.168.20.29' \
-e PGSQL_PASSWD='mypgsqlpassword' \
-e LISTEN_ADDR='0.0.0.0' \
faradaysec/faraday:latest
With config volume mounted
docker run \
-v ~/.faraday/doc:/faraday-license \
-v ~/.faraday/storage:/faraday-storage \
-v ~/.faraday/config:/faraday-config \
-p 5985:5985 \
faradaysec/faraday:latest
To check the container, run the following command:
docker container ls
As you can see, Faraday Server is running on port 5985.
As a service¶
-
Initialize a Swarm:
docker swarm init # In case you have more than one IP addr configured in your machine you have to specify which one to use. docker swarm init --advertise-addr=192.168.20.29
-
Docker Compose File: Now, you need to create a docker-compose.yml file. You can use this docker-compose as an example:
With environment variables
version: '4.02'
services:
server:
image: faradaysec/faraday:latest
environment:
- LISTEN_ADDR=0.0.0.0
- PGSQL_HOST=192.168.20.29
- PGSQL_USER=faraday_postgresql
- PGSQL_PASSWD=/run/secrets/pgsql_passwd
- PGSQL_DBNAME=faraday
secrets:
- pgsql_passwd
ports:
- 5985:5985
volumes:
- ~/.faraday/storage:/faraday-storage
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
secrets:
pgsql_passwd:
external: true
When Faraday runs as a service, PGSQL_PASSWD can be configured with Docker secrets (default in docker-compose.yml). The simplest way to create a secret is reading from standard input (you should take care of bash history).
printf mypgsqlpassword | docker secret create pgsql_passwd -
Once you have created the secret, edit your docker-compose.yml and set:
vim docker-compose.yml
version: 'latest'
services:
...
environment:
- PGSQL_PASSWD=/run/secrets/pgsql_passwd
...
For more information about secrets, check Docker’s web page
With config volume mounted
version: '4.02'
services:
server:
image: faradaysec/faraday:latest
ports:
- 5985:5985
volumes:
- ~/.faraday/storage:/faraday-storage
- ~/.faraday/config:/faraday-config
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
-
Deploy: Once you are done setting up your docker-compose.yml file, let's deploy it by running the following command:
docker stack deploy -c docker-compose.yml faraday
-
Check service: To check the service, run the following command:
docker service ls docker service logs faraday_server
Web UI¶
Once Faraday Server is running, you'll have to obtain the container's IP address. For this, run:
docker inspect $(docker ps -lq) | grep \"IPAddress
This command will throw the following output:
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
Now you can direct your browser to http://172.17.0.2:5985/_ui/
We highly recommend you to check our First Steps guide.