The image includes a Nodejs + WebKit, Chromium, Firefox
462
Original repository https://github.com/webpanorg/browsers. The image works on amd64 and arm64 architectures. The Dockerfile includes a Nodejs + WebKit, Chromium, Firefox
The image is based on Ubuntu. Images from Playwright are used in the image. The main reason for not using the official Playwright image is that the browser build versions (revisions) depend on the Playwright version, information which is located in playwright-core/browsers.json. You can learn more about installing browsers through Playwright here: https://playwright.dev/docs/browsers#install-browsers Additional packages such as xvfb, ffmpeg, and vnc have been added to the image.
Example Dockerfile using this image:
FROM webpanorg/browsers:latest
ENV USER_DIR /home/user
# ----- Add not root user ----- #
ENV USER_ID=999
RUN groupadd -r user && useradd --uid ${USER_ID} -r -g user -G audio,video user
RUN mkdir -p $USER_DIR
RUN chown -R user:user $USER_DIR
RUN chown -R user:user /usr/src
USER user
WORKDIR $USER_DIR
COPY --chown=user src ./src
COPY --chown=user package.json ./package.json
COPY --chown=user tsconfig.json ./tsconfig.json
RUN npm install
# expose vnc
EXPOSE 5900
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "start"]
Example of using Chrome + Puppeteer in Docker:
import * as puppeteer from 'puppeteer-core';
const DISPLAY = ':99';
(async () => {
const browser = await puppeteer.launch({
headless: false,
executablePath: '/usr/src/chromium/chrome',
env: {
DISPLAY
},
ignoreDefaultArgs:["--disable-extensions", "--enable-automation"],
args: [
"--start-maximized",
'--window-position=000,000',
'--window-size=1920,1080',
'--disable-dev-shm-usage',
'--no-sandbox',
'--no-first-run',
'--no-zygote',
'--metrics-recording-only',
'--enable-automation',
'--mute-audio',
],
defaultViewport: {
width: 1920,
height: 1080
}
});
await browser.close();
})();
Example of using firefox in Docker:
import * as playwright from 'playwright-core';
const DISPLAY = ':99';
(async () => {
const browser = await playwright.firefox.launch({
headless: false,
executablePath: '/usr/src/firefox/firefox',
env: {
DISPLAY
},
args: [
'--window-position=000,000',
'-width=1920',
'-height=1080',
"--start-maximized"
],
});
// Create a new incognito browser context.
const context = await browser.newContext({
viewport: {
width: 1920,
height: 1080
}
});
await context.close();
await browser.close();
})();
Example of using chromium in Docker:
import * as playwright from 'playwright-core';
const DISPLAY = ':99';
(async () => {
const browser = await playwright.chromium.launch({
headless: false,
executablePath: '/usr/src/chromium/chrome',
env: {
DISPLAY
},
args: [
'--window-position=000,000',
'--window-size=1920,1080',
"--start-maximized"
],
});
// Create a new incognito browser context.
const context = await browser.newContext({
viewport: {
width: 1920,
height: 1080
}
});
await context.close();
await browser.close();
})();
Example of using Webkit in Docker:
import * as playwright from 'playwright-core';
const DISPLAY = ':99';
(async () => {
const browser = await playwright.webkit.launch({
headless: false,
executablePath: '/usr/src/webkit/pw_run.sh',
env: {
DISPLAY
},
args: [],
});
// Create a new incognito browser context.
const context = await browser.newContext({
viewport: {
width: 1920,
height: 1080
}
});
await context.close();
await browser.close();
})();
Content type
Image
Digest
sha256:c8d858f32…
Size
1.1 GB
Last updated
over 2 years ago
docker pull webpanorg/browsers