I have dockerized two services:
- web frontend(containing the gui in angular accessed on port 3000)
- backend(that has puppeteer dependency for extracting data from a web page accessed on port 8111)
Below is the simplified version dockerfile for the backend:
FROM private/node:v10.22.1
# Dependencies needed for backend (removed for simplicity)
RUN apt-get update
RUN apt-get install -y ...
USER root:root
COPY ./backend /node/backend
WORKDIR /node/backend
RUN npm install --unsafe
CMD npm start
EXPOSE 8011
They communicate with each other with sock.io
.
The backend has two modes of running the extraction(headless and headful). The headless extraction works successfully with these dockerized services.
The headful extraction when running the backend locally it pops up web browser containing the page that is being processed. When headful extraction is enabled on the dockerized backend that it fails because the container doesn't have GUI.
To fix the headful extraction on the backend I have modified the docker file below:
FROM private/node:v10.22.1
# Dependencies needed for backend (removed for simplicity)
RUN apt-get update
RUN apt-get install -y ...
# Adding dependecies that are needed to create fake display in container
RUN apt-get update &&\
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
xvfb x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps
USER root:root
COPY ./backend /node/backend
WORKDIR /node/backend
RUN npm install --unsafe
# Creating display
ENV DISPLAY :99
# CMD npm start
CMD Xvfb :99 -screen 0 1024x768x16 & npm start
EXPOSE 8011
And I am running both containers without network isolation like below:
docker run --network host web
docker run --network host --env="DISPLAY" backend
After these changes, the headful extraction works successfully but the browser windows don't pop up.
- Why isn't the browser windows popping up?
- This should be able to work also for the Windows host machine where is not possible to remove network isolation. Is it possible to achieve popping a browser from the container to the host machine without removing the network isolation?
Kind Regards, Rando.
P.S
I trying to achieve to run the GUI of the web browser that is started inside the container in the host where the host is Windows. I need to know if it is possible to achieve this where the container is Linux and the host is Windows and the removal of network isolation(net=host
) is not possible.