I have running docker an AWS EC2 instance. Using docker-compose, I have jenkins running in one container. I have a jenkins pipeline which checks out my repo ( which is a Djano application, with a docker file ). My pipeline then builds the docker image using the Docker file. This is build on the host docker daemon as I have mapped these volumes in my docker-compose file
volumes:
- /var/run/docker.sock : /var/run/docker.sock
The image is built successfully, and I can run commands in this image from my jenkins pipeline using
img = docker.build(....)
img.inside{
sh '.....'
}
But when I try to run my Django tests using
img.inside{
sh 'python manage.py test'
}
Tests which inherit from TestCase run successfully. But I have tests which are subsets of StaticLiverServerTestCase, they use selenium. I get an error when trying to initialize my Webdriver instance:
browser = WebDriver()
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: address not available.
These tests run successfully on the exact same setup on my local machine
docker-compose run web python manage.py test
My guess is that it could be something wrong with AWS security groups and port access. The LiveServerTestCase might by trying to use a port which the AWS security group does not allow. But I tried enabling TCP access to all ports from internal traffic, but this also does not work.
Please has anyone encountered any similar problems or has any tips for me.