Skip to content

Instantly share code, notes, and snippets.

@linw1995
Created February 27, 2018 06:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save linw1995/3aeaf9f70b41ec9e4769da27b5c30619 to your computer and use it in GitHub Desktop.
Save linw1995/3aeaf9f70b41ec9e4769da27b5c30619 to your computer and use it in GitHub Desktop.
Google Chrome Headless Docker
FROM google/debian:jessie
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qqy \
&& apt-get -qqy install \
gnupg wget ca-certificates apt-transport-https \
ttf-wqy-zenhei \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install google-chrome-stable \
&& rm /etc/apt/sources.list.d/google-chrome.list \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 \
&& chmod +x /usr/bin/dumb-init
RUN cp /etc/localtime /etc/localtime.bk \
&& rm /etc/localtime \
&& ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& dpkg-reconfigure tzdata
RUN useradd headless --shell /bin/bash --create-home \
&& usermod -a -G sudo headless \
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& echo 'headless:nopassword' | chpasswd
RUN mkdir /data && chown -R headless:headless /data
USER headless
ENTRYPOINT ["/usr/bin/dumb-init", "--", \
"/usr/bin/google-chrome-stable", \
"--disable-gpu", \
"--headless", \
"--no-sandbox", \
"--disable-setuid-sandbox", \
"--hide-scrollbars", \
"--disable-dev-shm-usage", \
"--remote-debugging-address=0.0.0.0", \
"--remote-debugging-port=9222", \
"--user-data-dir=/data"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment