Permission denied - Attempting to run Docker from XCTestCase

I'm setting up tests for my Xcode Multiplatform App. To create a test environment I created a docker image that I want to run an XCTestCase against. I understand I'd have to make sure Docker is running before running the test. That said I have a permission denied when trying to connect to the docker daemon socket.

Background: I'm using a makefile to store the commands and planned to run the docker build and docker run commands in the setUpWithError while running the docker kill command in tearDownWithError. To run the commands I used Process to execute the shell commands. I'm currently doing this is a test function to get it up and going.

Issue: When I try to run the docker command Xcode tells me that it doesn't give me the permission to run it:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=remarkable": dial unix /var/run/docker.sock: connect: operation not permitted.

See 'docker run --help'.

I only want to use Docker to run this specific XCTestCase. Is there anyway to run it from here JUST for the test? Or do I need to manually run docker and kill it before/after I run these tests?

Thanks for any help.

Permission denied - Attempting to run Docker from XCTestCase
 
 
Q