Open slehernaf opened 2 years ago
Hi! Do you have CRA and ClamAV started in docker?
No, i tried started with ClamAV in docker, but the error still remained
But CRA is started inside container? If so, you cannot use localhost/127.0.0.1 as Clamavd address because localhost/127.0.0.1 inside container is not the same as your host ;)
I'm sorry, I just started dealing with dockers and I don't understand a lot yet, so I can only give screenshots.
Here is a port scan:
Here it shows how the image is launched, that the container is created and disappears, and logs
You can also see here that the container is running on 3310/tcp, this is the clamav/clamav image
OK. So here is the problem: you have not specified CLAMD_IP
env variable for CRA container so it defaults to localhost/127.0.0.1 (you just copy paste command from README without pointing to proper config file).
You have to set this environment variable to your host (computer you are running docker-engine) IP. You can do this by running CRA container with the command:
docker run -d -p 8080:8080 -e NODE_ENV=production -e APP_PORT=8080 -e APP_FORM_KEY=FILES -e CLAMD_IP=<put_here_ip_address_of_your_machine> benzino77/clamav-rest-api
clamav/clamav:latest - I'm running the clamav docker container & ip address added in .env CLAMD_IP - 172.17.0.2
got this ip address by below command docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' de7a835c5681
But still getting error as ECONNREFUSED
Ist there any steps to follow?
You should not use it that way - that address will change every time you restart clamavd container. Have a look in the examples folder If you do not want to use docker-compose you should try to set up things like that:
@benzino77 I m facing the same error. I am trying to start clamav-rest-api
app by cloning the repo and running the clamav
docker container locally. But for some reason, I am facing ECONNREFUSED
error.
P.S - I have tried with setting the ENV variables in different ways (.env
file and also as shown in the screenshot) with VM IP
address, 127.0.0.1
and localhost
for CLAMD_IP
- but the result is the same
CRA will not start if there is no clamav daemon available (or I should rather say there is no clamavd with open 3310 port available). As I can see from the screenshot you provided you have not publish clamav port to the host. You should start clamav container by something similar to:
docker run -d --name clamavd -p 3310:3310 clamav/clamav:stable
The important part is -p 3310:3310
Thank you, that worked! I think it is better to update the README
about the same, since I do not see this info there. Cheers!
Thank you, that worked! I think it is better to update the
README
about the same, since I do not see this info there. Cheers!
PRs are welcome ;)
Hi i m running in kubernetes clamav and cra, i changed cra service type from nodeport to loadbalancer because i need an public ip for the endoint, is working for a day and after a day i receive { "success": false, "data": { "error": "connect ECONNREFUSED 10.0.0.86:3310" } }
Hi, That is because there is no clamav service available. Where do you try to start CRA: Docker? K8S?
could you please provide your setup: docker-compose.yaml or your k8s manifests?
Hi, thank you for quick respose, please see the manifests below: apiVersion: apps/v1 kind: Deployment metadata: name: clamavd-deployment labels: app: clamavd spec: replicas: 1 selector: matchLabels: app: clamavd template: metadata: labels: app: clamavd spec: containers:
apiVersion: v1 kind: Service metadata: name: clamavd-service spec: selector: app: clamavd ports:
apiVersion: apps/v1 kind: Deployment metadata:
name: cra-deployment labels: app: cra spec: replicas: 1 selector: matchLabels: app: cra template: metadata: labels:
# the Deployment label selector to this value
app: cra
spec:
containers:
- name: clamav-rest-api
# Run this image
image: benzino77/clamav-rest-api
command: ['/usr/bin/wait-for-it', '-h', 'clamavd-service', '-p', '3310', '-s', '-t', '60', '--', 'npm', 'start']
env:
- name: NODE_ENV
valueFrom:
configMapKeyRef:
name: cra-configmap
key: node-env
- name: CLAMD_IP
valueFrom:
configMapKeyRef:
name: cra-configmap
key: clamd-ip
- name: APP_FORM_KEY
valueFrom:
configMapKeyRef:
name: cra-configmap
key: app-form-key
- name: APP_MAX_FILE_SIZE
valueFrom:
configMapKeyRef:
name: cra-configmap
key: app-max-file-size
ports:
- containerPort: 3000
protocol: TCP
name: cra-port
apiVersion: v1 kind: Service metadata: name: cra-service annotations:
spec: type: LoadBalancer selector: app: cra ports:
is working for a day lets say and next day the error
I do not know why, but during startup, the container is displayed as active and disappears after 2-3 seconds, this error is found in the logs
Cannot initialize clamav object: Error: connect ECONNREFUSED 127.0.0.1:3310
netstat -lnp | grep -E "(clam|3310|docker)"
->