Skip to content

Fix firewalld reload in Docker deployment#1

Open
erfansahaf wants to merge 1 commit into
masterfrom
fix/docker-firewalld-reload
Open

Fix firewalld reload in Docker deployment#1
erfansahaf wants to merge 1 commit into
masterfrom
fix/docker-firewalld-reload

Conversation

@erfansahaf
Copy link
Copy Markdown
Owner

Summary

This PR fixes the firewalld reload functionality when running the application inside a Docker container.

Problem

The original implementation tried to call firewall-cmd --reload inside the Docker container, but:

  1. The container didn't have access to the firewalld socket (/var/run/firewalld/)
  2. The firewall-cmd client wasn't installed in the container
  3. This caused silent failures and the rules weren't being reloaded

Solution

  1. Install firewalld client in Dockerfile - Added apt-get install -y firewalld to install the firewalld client (not the daemon) inside the container
  2. Mount firewalld socket - Added /var/run/firewalld:/var/run/firewalld volume mount in docker-compose.yml to expose the host's firewalld socket to the container
  3. Run as root - Added USER root in Dockerfile to ensure proper permissions to access the socket
  4. Improved error handling - Enhanced the /reload endpoint to return proper JSON responses with helpful error messages

How it works

When running in Docker:

  • The container has firewall-cmd installed (client only)
  • The firewalld socket from the host is mounted into the container
  • When /reload is called, it uses the mounted socket to communicate with the host's firewalld daemon over DBus
  • The host's firewalld is signaled to reload its rules

Testing

The changes have been made locally. To test:

  1. Ensure firewalld is running on the host machine
  2. Build and run the container with docker compose up --build
  3. Make changes to firewall rules through the GUI
  4. Click the reload button - it should now successfully reload firewalld

- Install firewalld client in container to communicate with host's firewalld daemon
- Mount firewalld socket from host into container
- Run container as root to access the socket
- Improve error handling in reload endpoint with proper JSON responses
- Update docker-compose.yml with socket mount configuration
- Update documentation with Docker deployment instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants