0

I'm in a somewhat weird situation that I don't understand:

  • I use ufw as a firewall. It's setup to drop any input connections apart from ssh
  • I have a service running locally (managed through systemd) that accepts connections on port 9500
  • I have another service managed with docker-compose. It needs to talk to the service on my host at port 9500 + a Redis container
  • Nothing needs to come in from the outside, it's all happening on my machine

UFW config:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         LIMIT IN    192.168.0.0/24            

Docker config:

  my_service:
    ...some stuf...
    depends_on:
      - redis
    extra_hosts:
      - "host.docker.internal:host-gateway"

  redis:
    container_name: redis
    restart: unless-stopped
    image: redislabs/rejson:2.0.8
    ports:
      - 6379:6379
    healthcheck:
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]

When I run this setup with ufw DISABLED, everything works. my_service running in Docker can talk to the service managed by systemd on port 9500 by contacting host.docker.internal:9500, and it can also talk to Redis, which is on Docker's network.

However if I ENABLE ufw, my_service can't talk to the systemd service. I don't understand why this happening. I thought this was because I didn't allow traffic coming from localhost, so I tried that:

# ufw allow from 127.0.0.1

But it didn't help, the traffic isn't coming through. Could you help me understand what is happening please?

1 Answer 1

0

Your docker container doesn't come from IP 127.0.0.1 or from 192.168.0.0/24. Probably it will have an IP like 172.22.0.5. Use docker inspect <your container> to look up its IP address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .