Testing a client using a service container running the application
Asked by David Engelmann:

I have an application called doccano that's built with docker/docker compose and spins up a series of different containers to run the application. I have a package that is a client for interacting with the doccano application that I wish to test. I'm looking at spinning up the doccano application as a service for the pipeline. In the steps, I would like to be able to build my client package and test it against the running doccano service. If someone can just get me to being able to ping the service container from the step, the rest is trivial. This was very simple with github actions.

....  
services:  
doccano:  
image:  
name: doccano/doccano  
...

- step:

name: test  
services:  
- doccano  
script:  
- export COMPOSER_ALLOW_SUPERUSER=1  
- apt-get update -qq  
- apt-get install apt-transport-https ca-certificates gnupg lsb-release git curl iputils-ping -y  
- ping -c 1 doccano


Answers:
author: Mark C
body: Hi [@David Engelmann](/t5/user/viewprofilepage/user-id/5135870),

Welcome to the community.

I do believe the Docker image doccano/doccano is not intended to be used as a service on Pipelines as compared to [MySQL Docker image here](https://hub.docker.com/layers/library/mysql/latest/images/sha256-41932716f7d57462d4f017d8334b60dfb2af5ec973db22e262619c16bd5048e6?context=explore).  
This is why you can't use the Docker image as a service directly.

What you could try differently is to run a Docker container directly on Pipelines using Docker commands (e.g. **docker run** ).  
Alternatively, you can also try using **docker-compose** as mentioned on the [doccano Docker hub overview page](https://hub.docker.com/r/doccano/doccano).

Regards,  
Mark C

comments: author: David Engelmann
body: I use the doccano image as a service in Github Actions without any issue, here is the workflow file - <https://github.com/david-engelmann/DoccanoClient.jl/blob/main/.github/workflows/doccano_init.yml>. I've tried installing it from docker run and docker compose and I'm not able to find a way to test interacting with it.


author: Mark C
body: Hi [@David Engelmann](/t5/user/viewprofilepage/user-id/5135870),

After further testing, instead of pinging the service, you can access it via the localhost on the specified port 8000.  
Here's the exact YAML configuration that I used:

```
definitions:  services:    test-service:      image: doccano/doccano      variables:        ADMIN_USERNAME: admin        ADMIN_EMAIL: test123@gmail.com        ADMIN_PASSWORD: password        PORT: 8000pipelines:   default:     - step:         script:           - curl http://127.0.0.1:8000/        services:          - docker          - test-service
```

Hope it helps and do let me know if you have further questions.

Regards,  
Mark C


author: David Engelmann
body: Hi Mark, thank you for all your help. I've been able to see the presence of the services but my issue comes when trying to interact with it. Such as a POST request to test the login and csrf token mechanics. There isn't a technical/security reason why this would be impossible correct?


author: Mark C
body: Hi [@David Engelmann](/t5/user/viewprofilepage/user-id/5135870),

You'll just need to be aware of the limitations for **services** on Pipelines as highlighted in [this documentation](https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/).

Regards,  
Mark C


Tags: bitbucket-cloud

bitbucket-pipelines

cloud