Closed ghost closed 3 years ago
In your Ansible config you'll have to remove the cap-drop
and user
settings. The user
setting will start the container as the the Suricata user. For Suricata to run properly it needs to be root. If it has the capabilities sys_nice
and net_admin
, it will change its uid to the suricata
user after its done what it needs to do as root.
And the cap-drop
option appears to remove capabilities that are previously added. So unless you need to drop specific capabilities, I'd leave this option out. Suricata needs the sys_nice
and net_admin
capabilities so it can stop running as root, yet operate normally.
Thanks @jasonish. That solved this issue. Now I need to figure out why the container exits as soon as it is started.
Try a command of "-i
I'm not really sure how Ansible is doing this.. Maybe its rebuilding the image? But you want to replicate this:
docker run --rm -it --net=host \
--cap-add=net_admin --cap-add=sys_nice \
jasonish/suricata:latest -i <interface>
with your own mounts of course. Your volume mounts do look OK.
I still need to streamline (or simply document) the process of rule updates and log rotation with Suricata in Docker though.
I think that is the problem. The Ansible module doesn't have an obvious way to specify the interface for the host network. I need to work with them to see if it can or can't be done now. Feel free to close this issue. Your code is working fine. Thanks for your help.
That shouldn't be needed.. Host network in Docker just exposes all the interfaces on the host inside the container, almost as if the app wasn't running in the container.. So eno1 on the host is eno1 inside the container and so on.
That makes sense. I just wish Ansible had a way to specify the one I want to use then it would support the -i option.
I figured out I can specify the -i option through CMD. Now the container runs fine. I will close this as everything is now working perfectly.
Operating System
CentOS 7
Ansible
I am creating the container using the Ansible docker_container module.
Ansible Options
Ansible Command
Expected Outcome
container successfully created and running
Actual Output
$ sudo docker run --rm -it jasonish/suricata:latest /bin/bash
ls -l /etc/suricata
total 92 -rw-------. 1 suricata suricata 4258 Sep 15 05:55 classification.config -rw-------. 1 suricata suricata 1375 Sep 15 05:55 reference.config -rw-------. 1 suricata suricata 70491 Sep 15 05:55 suricata.yaml -rw-------. 1 suricata suricata 1644 Sep 15 05:55 threshold.config -rw-rw-r--. 1 suricata suricata 43 Sep 15 05:49 update.yaml