Here's my problem. I'm using custom docker image based on "php:7.3-apache" in Pipelines. When the pipeline runs I'm getting "Connection refused" when trying to curl / connect to port 80. This does not happen when I use the original "php:7.3-apache" image. What is weird is that the custom image works locally just fine and I'm able connect to port 80. The issue seems to be present only in Pipelines.
RUN apt-get update && apt-get install -y netcat # Only for debugging purposes
RUN docker-php-ext-install pdo pdo_mysql
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- nc -zv 127.0.0.1 80
- echo "TEST" > /var/www/html/test.html
- curl -v http://127.0.0.1/test.html
Response to the above
nc: connect to localhost (127.0.0.1) port 80 (tcp) failed: Connection refused
Running the image locally
root@b4325d0e00d1:/var/www/html# nc -zv 127.0.0.1 80
Connection to 127.0.0.1 80 port [tcp/*] succeeded!
Any ideas what is the issue and how to get around this?
@Hannu Pölönen try to go with
nc -zv 0.0.0.0 8080
Also, I suspect there is something wrong with your network bridge in docker container OR you don't use `services` keyword. I suppose , you just don't create any connection. I have a recipe for you that may suit if don't necessarily need to install anything:
Check out services definitions in bitbucket pipelines https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/
You may use approach sth like this
definitions: services: my-apache-service: image: php:7.3-apache variables: MY_VARIABLE: 'value' ...
- nc ...
If you have some custom image , you can push to docker registry first and then use it.
I gave this a shot and it indeed seems to work correctly if I create a separate service container for the one running apache. I suppose creating a separate service container for apache is the way to go.
The only thing I don't still quite get is why I would need to create a separate container only when using a custom docker image?
@Hannu Pölönen because for now I don't know (may be you found the way, however), if there is a possibility for you to use custom image in the services definitions, if you did not push it to your docker registry before.
I know that services in their definitions accept docker registry image with tag, and I don't know currenlty, which syntax would be for service definition if you want to run docker container locally in pipeline, without pushing it first.
But if you succeeded, we are happy. If you want - welcome to share how you did it.
Hi @Halyna Berezovska, I did push my custom image to the docker registry before trying to use it in pipelines. It is however a private docker repo so I'm not able to share the image.
I was able to get around the issue for now but it's not really a permanent solution. I will definitely share my final solution / findings once I get back to this project.
@Hannu Pölönen you can also use private image as definition https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/#[hardBreak]Use-a-private-image
If you have aws ecr image, then you can also use ecr uri with aws credentials
Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events