Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Connect to Selenium service from within docker container

In Pipelines I can install a Drupal site successfully and from within its container I can access it at http://localhost:80. I am executing Behat tests and non-@javascript scenarios are working (via goutte) but @javascript scenarios are failing (via selenium2). I get the following error when running a @javascript scenario:

unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=89.0.4389.82)
  (Driver info: chromedriver=89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}),platform=Linux 5.4.92-flatcar x86_64) (WebDriver\Exception\UnknownError)

I'm wondering if it's possible to connect to the Selenium service from within the container?

In a build step, I run:

docker exec -i app bash -c "echo \"$BITBUCKET_DOCKER_HOST_INTERNAL host.docker.internal\" >> /etc/hosts"

This allows me to access the mysql service at host.docker.internal:3306 from within the container.

I assume the same should work for the Selenium service, making it accessible at host.docker.internal:4444 from within the container but the error above is output.

Here is part of my bitbucket-pipelines.yml file to help provide some more context:

    - step:
          - docker build -t my-ci .
          - docker run -dit --name app -p 8080:80 my-ci
          - sleep 5
          - docker ps
          - docker exec -i app bash -c "echo \"$BITBUCKET_DOCKER_HOST_INTERNAL host.docker.internal\" >> /etc/hosts && /var/www/vendor/drush/drush/drush si --db-url=mysql://drupal:drupal@host.docker.internal:3306/drupal -vvv"
          - docker exec -i app bash -c "curl http://localhost:80/user/login"
          - docker exec -i app bash -c "cd /var/www/tests/behat && composer install && bin/behat"
          - docker
          - mysql
          - google-chrome

      image: mysql:5.7
        MYSQL_DATABASE: 'drupal'
        MYSQL_USER: 'drupal'
        MYSQL_ROOT_PASSWORD: 'root'
        MYSQL_PASSWORD: 'drupal'
      image: selenium/standalone-chrome

1 answer

1 accepted

0 votes
Answer accepted

After a lot of trial and error I realized the mapping of 8080:80 was causing issues. Instead I mapped 80:80 and I can now successfully run my Behat @javascript tests.

Suggest an answer

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

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,477 views 4 7
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