cat Dockerfile.chrome FROM centos MAINTAINER zh******ech.cn ENV LANG en_US.UTF-8 RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone WORKDIR /home RUN mkdir node COPY node-v8.14.0-linux-x64.tar.gz /home/ RUN tar zxf /home/node-v8.14.0-linux-x64.tar.gz -C /home/node ENV PATH PATH=$PATH:$HOME/bin:/home/node/node-v8.14.0-linux-x64/bin RUN npm install pm2 -g COPY google-chrome.repo /etc/yum.repos.d/ RUN yum install -y google-chrome-stable EXPOSE 9999 ENTRYPOINT pm2 start google-chrome --interpreter none -- --headless --disable-gpu --disable-translate --disable-extensions --disable-background-networking --safebrowsing-disable-auto-update --disable-sync --metrics-recording-only --disable-default-apps --no-first-run --mute-audio --hide-scrollbars --no-sandbox --remote-debugging-port=9999 && tail -f /var/log/yum.log
cat google-chrome.repo [google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1 gpgcheck=0 gpgkey=https://dl.google.com/linux/linux_signing_key.pub
构建镜像 docker build -t google-chrome -f Dockerfile.chrome . Sending build context to Docker daemon 17.22 MB Step 1/14 : FROM centos ---> 1e1148e4cc2c ****** ---> Using cache ---> c8a445ff31da Successfully built c8a445ff31da
启动容器 [root@weifeng02 google-chrome]# docker run -d -p 9999 google-chrome 03ecfddd9c220b599fdf4310fe6a331f6c988a09352d27353bce5053f08ab022 [root@weifeng02 google-chrome]# [root@weifeng02 google-chrome]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 03ecfddd9c22 google-chrome "/bin/sh -c 'pm2 s..." 5 seconds ago Up 5 seconds 0.0.0.0:32790->9999/tcp awesome_jang