title: Docker network, accessing a service in a docker-compose file when executing the docker run command
body: <p>I have a docker-compose file like so</p>
  <pre class="lang-sh prettyprint-override"><code>version: '3'
  networks:
    default:
      external: true
      name: selenoid
  services:
    selenoid:
      image: aerokube/selenoid:latest-release
      volumes:
        - &quot;$PWD/config:/etc/selenoid&quot;
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
      environment:
        - OVERRIDE_VIDEO_OUTPUT_DIR=$PWD/video
      command: [&quot;-conf&quot;, &quot;/etc/selenoid/browsers.json&quot;]
      ports:
        - &quot;4444:4444&quot;
    selenoid-ui:
      links:
         - selenoid
      image: aerokube/selenoid-ui
      ports:
        - &quot;8080:8080&quot;
      command: [&quot;--selenoid-uri&quot;, &quot;http://selenoid:4444&quot;]
  </code></pre>
  <p>This spins up the selenoid service. From my python script I would like to access this service.</p>
  <pre><code>driver = seleniumwebdriver.Remote(
  command_executor=&quot;http://selenoid:4444/wd/hub&quot;,
  options=chrome_options)
  </code></pre>
  <p>The python script is executed inside a docker container:</p>
  <pre class="lang-sh prettyprint-override"><code>docker run \
      --network=&quot;selenoid&quot; \
      --rm \
      -v $PWD/pythoncode:/pythoncode \
      -w /pythoncode \
      python:3.8.12 /bin/bash -c \
      &quot;pip install -r requirements.txt &amp;&amp; \
      python3 main.py&quot;
  </code></pre>
  <p>But I can't reach the service from the python script.</p>
  <p>The network is created with</p>
  <pre class="lang-sh prettyprint-override"><code>docker network create selenoid
  </code></pre>
  <p>And i've checked that all containers are there with</p>
  <pre class="lang-sh prettyprint-override"><code>docker network inspect selenoid
  </code></pre>
  <p>But still I can't reach the service from my python script.</p>
  <p>i get the following error</p>
  <blockquote>
  <p>File &quot;main.py&quot;, line 16, in 
  driver = seleniumwebdriver.Remote(   File &quot;/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py&quot;,
  line 266, in <strong>init</strong>
  self.start_session(capabilities, browser_profile)   File &quot;/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py&quot;,
  line 357, in start_session
  response = self.execute(Command.NEW_SESSION, parameters)   File &quot;/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py&quot;,
  line 418, in execute
  self.error_handler.check_response(response)   File &quot;/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py&quot;,
  line 243, in check_response
  raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: wait:
  <a href="http://172.17.0.2:4444/" rel="nofollow noreferrer">http://172.17.0.2:4444/</a> does not respond in 30s</p>
  </blockquote>