Docker
Prerequisites: Before proceeding with the installation of Evolution API v2 using Docker, make sure you have already configured the necessary services, such as PostgreSQL and Redis. Follow the links below for more details:
These installation instructions assume that you have already installed Docker on your machine. You can find information on how to install Docker in the
Official Docker Documentation.
Evolution API v2 is Docker-ready and can be easily deployed with Docker in standalone or swarm mode. The official Evolution API repository contains all the necessary composition files to install and run the API.
Docker Compose
Deploying Evolution API v2 using Docker Compose simplifies the setup and management of your Docker containers.
It allows you to define your Docker environment in a docker-compose.yaml
file and then use a single command to start everything.
Docker Compose File
The following example illustrates how to configure Docker Compose for standalone environments, i.e., a single running server. For syncing two servers in parallel or for greater scalability, use Docker Swarm, recommended for more advanced users.
Standalone Configuration
Attention: The commands described here as docker compose
may not work in older versions of Docker.
If you are using an older version, replace with docker-compose
.
Docker standalone is suitable when Evolution API will run on just one machine, without the need for immediate scalability. This is the most convenient method for most users.
To get started, create a docker-compose.yml
file with the following content:
Next, create a .env
file in the same directory with the following minimal content:
For more configurations, you can get the example file from the official repository. Also, check the environment variables guide here.
Starting the API
Navigate to the directory containing the docker-compose.yml
file and run the following command to start the services defined in the file:
This command will download the necessary Docker images, create the defined services, networks, and volumes, and start the Evolution API service.
Checking the Logs
After running the docker compose up
command, you can check the logs to confirm that the services are running correctly:
Stopping the Service
To stop the service, use the command:
Accessing the API
Open your browser and go to http://localhost:8080 to check if the Evolution API is operational.
Docker Swarm
To set up and manage a Docker Swarm cluster for Evolution API v2, follow the instructions below. Docker Swarm is ideal for environments that require scalability and high availability.
Docker Swarm Installation
Configuring the Manager Server
If you are using a Hetzner server, run:
Step 1: Hostname Configuration
- Change the machine’s hostname to identify it in the cluster:
- Edit the
/etc/hosts
file to add the new name:
Add the line:
- Reboot the system to apply the changes:
- Check the hostname:
Step 2: Docker Installation
Install Docker by running:
Step 3: Starting the Swarm
Start Docker Swarm:
Step 4: Docker Swarm Network Configuration
Create the overlay network for Docker Swarm:
Note the command generated to register the Workers:
Configuring the Worker Server
If you are using a Hetzner server, run:
Step 1: Hostname Configuration
- Change the machine’s hostname to identify it in the cluster:
- Edit the
/etc/hosts
file to add the new name:
Add the line:
- Reboot the system to apply the changes:
Step 2: Docker Installation
Install Docker by running:
Step 3: Adding the Worker to the Cluster
Run the previously obtained command to add the Worker to the cluster:
Prerequisites for Evolution API via Swarm
Installing Traefik
To install Traefik on Docker Swarm, follow the instructions below:
- On the manager server, create a
traefik.yaml
file:
- Add the following content to the file:
- Run the following command to deploy the Traefik stack:
Deploying Evolution API v2
Finally, to deploy Evolution API v2 on Docker Swarm, use the configuration file available here with the following content:
After configuring and saving the file, deploy the stack with the command:
Accessing the API
Open your browser and go to https://evo2.site.com to check if the Evolution API is operational.