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

Connecting to MySQL in container

Luis Cruz Jun 27, 2016

For my pipeline, I am pulling down the docker image tutum/lamp  to provide a full stack to test against. One of my pipeline steps is to create the various databases I need. However, the commands I am issuing fail with this message:

$ mysql --user=root --port=3306 --host=localhost < sql_scripts/create_app_dbs.sql

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

 

If I pull this docker image locally, run it, and ssh into it, I can execute mysql --user=root --port=3306 --host=localhost and connect without issue. Stumped as to why this is happening. From the documentation, it seems like the steps should be running inside the container, but this error makes me feel like it might be running outside of the container.

 

EDIT: Digging in deeper, it appears the docker run invocation is different than what I do locally. When I run it, a series of scripts initiated by the Dockerfile brings up MySQL, but the pipelines process does not run these.

2 answers

1 accepted

1 vote
Answer accepted
Philip Hodder Atlassian Team Jun 27, 2016

You are right about Bitbucket Pipelines not running run.sh. You can run it inside of your build instead.

Try the following bitbucket-pipelines.yml:

image: tutum/lamp
pipelines:
    default:
        - step:
            script:
                - bash /run.sh & # Start the MySQL, run.sh is located in root directory
                - sleep 20 # So that MySQL has time to start up.
                - mysql --user=root --port=3306 --host=localhost < sql_scripts/create_app_dbs.sql
Luis Cruz Jun 28, 2016

Had tried running run.sh in various ways, but the bash in front finally did the trick.

Much obliged.

 

0 votes
Alex Soto Jun 27, 2016

I suppose you could execute those same series of scripts yourself in your pipelines yml?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,313 views 1 22
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