Z
Z
Zimaell2019-09-16 19:57:10
PHP
Zimaell, 2019-09-16 19:57:10

How to use docker in multiple threads?

At the moment I am running docker like this

docker run -e "CONNECTION_TIMEOUT=600000" -p 127.0.0.1:3000:3000 --restart always -d --name browserless browserless/chrome

And I use it in puppeteer (PHP) like this
$options=array(
    'headless'=>false,
    'defaultViewport'=>array('width'=>1440,'height'=>900,'isMobile'=>false),
    'ignoreHTTPSErrors'=>true,
    'ignoreDefaultArgs'=>true,
    'args'=>array('--incognito',
    '--0',
    '--window-size=1440,900',
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--ignore-certifcate-errors',
    '--ignore-certifcate-errors-spki-list',
    '--shm-size=2gb')
  );
$options['browserWSEndpoint']='ws://localhost:3000/?ignoreDefaultArgs=true&headless=false&'.implode('&',$options['args']);
$browser=$puppeteer->connect($options);

As far as I understand, I cannot run another script on the same port while this one is running, then how can I run it in several threads?
I assume that you need to run another docker with a different port (for example -p 127.0.0.1:3001:3001) and specify the same port in the php settings (ws://localhost:3001/?ignoreDefaultArgs=...).
Can you tell me if I am correct or should I do it differently?
Considering that the scripts will be run separately...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Brodsky, 2019-09-17
@DeathHand

Good time.
In general, if I understood everything correctly, you need to make a docker-compose.yml in which to describe this service.
Next, you need to use a command like:
Documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question