It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

docker-compose, mysql and bitbucket pipelines - how to make them play nicely Edited

I have a build step which

  • Installs docker-compose
  • runs docker-compose up to create
    • an api, connected to a
    • mysql container
    • test runner (newman container which calls the API)
  • Installs test data into the mysql container
  • runs a docker exec command on the test runner to kick off the tests against the api

Now, I have attempted to spin this up, by the mysql container fails when I try to install test data into it, because of the following error message is returned:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I am assuming this error message is related to the way bitbucket pipelines handles mysql as a service, so my container can't connect accordingly to the above socket.

I then read about spinning up a mysql service in my bitbucket pipelines step, which I did.  I was able to get my sample data loaded into the local mysql  database.  However, as my containerised API needs to access this mysql instance for its data, I was unable to work out the correct way to make the API even find the step's mysql server to use as its data store.  The mysql service runs on 127.0.0.1, but that doesn't work for a containerised app, as it has its own idea of what 127.0.0.1 means (aka itself).

1. Is it possible in any way to spin up my own mysql container as defined in my docker-compose file, and if so, how? If not
2. How can my containerised API access the step's mysql service, as this is running on 127.0.0.1?

 

1 answer

1 accepted

1 vote
Answer accepted

Okay, I hope this helps anyone else.  After scouring Atlassian's community and blog posts, I discovered some undocumented "features" to their mysql implementation, and how you can allow your docker-compose (or just plain docker) app to access the step's MySQL service.

https://medium.com/it-dead-inside/bitbucket-pipelines-docker-compose-and-database-hosting-9c81aa9311f3

Hope this helps someone.  It  took me forever to figure this one out.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,052 views 0 3
Read article

Community Events

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

Events near you