Create
cancel
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:

pipelines:
  default:
    - step:
        script:
          - 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"
        services:
          - docker
          - mysql
          - google-chrome

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: 'drupal'
        MYSQL_USER: 'drupal'
        MYSQL_ROOT_PASSWORD: 'root'
        MYSQL_PASSWORD: 'drupal'
    google-chrome:
      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
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

266 views 12 9
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