Running server in gitlab CI and running tests against it


What i am trying to do is run my server in gitlab CI and run tests against it.
When i run my test against my deployed server everything works fine tests pass.
But i run the server in gitlab CI and then run tests after some time i get client disconnected. ( server is running i tried sending a curl request and it worked fine )

I also tried creating a docker image for my server and adding it as a service
but the server does not seem to run
eg docker image

FROM python:3
CMD nohup python -m http.server 8000 &

In my .gitlab-ci.yml file

  stage: test
    - repo/testimage
    - ps -ef
    - curl -i http://localhost:8000 --insecure

the curl request gives connection refused