How to install Selenoid with Docker Compose? In this post, I will guide you how to do it easily.
Okay, if you don’t know what Selenoid is – it is a Selenium testing platform running browsers and mobile platforms in Docker containers. For more information about it, you can access Selenoid homepage.
Requirement
Table of Contents
Here is something that you need to prepare to install Selenoid:
- A server, I recommend you should use a Linux base server like Ubuntu server 20.04 64bit LTS.
- Pre-installed Docker, our tested with Docker version 20.10.10, build b485636.
- Pre-installed Docker Compose, our tested with docker-compose version 1.29.2, build 5becea4c.
Install Selenoid with Docker Compose
Now, it will be easy for you, I already uploaded the code to Github repository. You can clone it into your server and running up the service with just a command.
But I also write down it here for you.
Firstly, you should create a folder to contain all the files for Selenoid.
mkdir -p /opt/selenoid
Move to the folder were created above and create 2 files.
Create the file with name docker-compose.yml, copy content below to this file.
version: '3'
services:
selenoid:
image: "aerokube/selenoid"
network_mode: bridge
restart: unless-stopped
ports:
- "4444:4444"
volumes:
- "$PWD:/etc/selenoid/" # assumed current dir contains browsers.json
- "/var/run/docker.sock:/var/run/docker.sock"
selenoid-ui:
image: "aerokube/selenoid-ui"
network_mode: bridge
depends_on:
- selenoid
links:
- selenoid
restart: unless-stopped
ports:
- "8080:8080"
command: ["--selenoid-uri", "http://selenoid:4444"]
Create a second file name browsers.json and copy below content to this file.
{
"chrome": {
"default": "98.0",
"versions": {
"97.0": {
"image": "selenoid/chrome:97.0",
"port": "4444",
"path": "/"
},
"98.0": {
"image": "selenoid/chrome:98.0",
"port": "4444",
"path": "/"
}
}
},
"firefox": {
"default": "96.0",
"versions": {
"95.0": {
"image": "selenoid/firefox:95.0",
"port": "4444",
"path": "/wd/hub"
},
"96.0": {
"image": "selenoid/firefox:96.0",
"port": "4444",
"path": "/wd/hub"
}
}
},
"opera": {
"default": "83.0",
"versions": {
"82.0": {
"image": "selenoid/opera:82.0",
"port": "4444",
"path": "/"
},
"83.0": {
"image": "selenoid/opera:83.0",
"port": "4444",
"path": "/"
}
}
}
}
Now, the folder look like this.
[email protected]:/opt/selenoid# ls -al
total 20
drwxr-xr-x 3 root root 4096 May 9 13:59 .
drwxr-xr-x 7 root root 4096 May 9 08:38 ..
-rw-r--r-- 1 root root 1134 May 9 08:44 browsers.json
-rw-r--r-- 1 root root 540 May 9 08:42 docker-compose.yml
To run up Selenoid service, just execute follow command.
docker-compose up -d
To update the imager version for Selenoid, use this command.
docker-compose pull
docker-compose up -d
Remove Selenoid service, type this command.
docker-compose down
Check the result after installed Selenoid
Now, you can open your browser and type this link to access Selenoid service. Remember to open ports in server’s firewall. Replace 192.168.10.10 with your server’s IP address.
http://192.168.10.10:4444/status
Access the Selenoid UI.
http://192.168.10.10:8080
Conclusion
With a few commands, you already can install Selenoid service with Docker Compose in a Docker server.
This guide really easy for you following. Hope this post helpful for some guys, if you guys like it, please share and follow my blog.