爬虫环境-无头Debian系统配置
consol解决方案
参考项目:https://github.com/ConSol/docker-headless-vnc-container/tree/master
docker run方式
docker run -itd \
-p 5901:5901 \
-p 6901:6901 \
-e TZ=Asia/Seoul \
-e VNC_RESOLUTION=1280x720 \
-e VNC_PW=1234 \
--user 0 \
consol/debian-xfce-vnc
连接方式
connect via VNC viewer
localhost:5901
, default password:vncpassword
connect via noVNC HTML5 full client:
http://localhost:6901/vnc.html
, default password:vncpassword
connect via noVNC HTML5 lite client:
http://localhost:6901/?password=vncpassword
修改版本
docker run -itd \
--name test \
-p 9601:6901 \
-p 9602:5901 \
-e TZ=Asia/Seoul \
-e VNC_RESOLUTION=1280x720 \
-e VNC_PW=1234 \
-v $(pwd)/data:/headless/Desktop/data \
--user 0 \
consol/debian-xfce-vnc
docker compose方式
追加安装python3开发必须的一些应用包和软件
version: '3'
services:
debian-xfce-vnc:
image: consol/debian-xfce-vnc
ports:
- "9902:6901"
environment:
- VNC_RESOLUTION=1280x720
- VNC_PW=1234
volumes:
- ${PWD}:/headless/Desktop/app
user: "0"
command: >
/bin/sh -c "
apt-get update &&
apt-get -y install nano unzip openssl build-essential libssl-dev libffi-dev python3-dev python3-pip python3-venv chromium chromium-driver &&
echo '**** cleanup ****' &&
apt-get clean -y &&
rm -rf /config/.cache /tmp/* &&
echo '**** finished and Enjoy ****' &&
tail -f /dev/null
"
Dockerfile方式
构建自定义容器
## Custom Dockerfile
FROM consol/debian-xfce-vnc
ENV REFRESHED_AT 2022-10-12
# 设置时区
ENV TIME_ZONE Asia/Seoul
# Switch to root user to install additional software
USER 0
# 设置root密码
RUN echo 'root:1234' | chpasswd
# 更新
RUN apt-get update -y
# 安装开发包,可以省略
RUN apt-get -y install nano \
unzip \
openssl \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
python3-pip \
python3-venv \
chromium \
chromium-driver \
echo "**** cleanup ****" && \
apt-get clean -y\
rm -rf \
/config/.cache \
/tmp/*
## switch back to default user
USER 1000
安装后配置
# 安装包管理器
apt install gdebi
# 文本编辑器
apt install gedit
#
命令配置
# 安装基包软件
apt install git curl
# 静默模式不下载脚本直接安装python开发环境配置脚本
curl -fsSL https://github.com/emix1984/CustomizeServerEnvironment/raw/refs/heads/main/Setup_DebianXfceVNC_PythonDev.sh | bash
# 下载脚本并且安装python开发环境配置脚本
curl -O https://raw.githubusercontent.com/emix1984/CustomizeServerEnvironment/refs/heads/main/Setup_DebianXfceVNC_PythonDev.sh && chmod +x Setup_DebianXfceVNC_PythonDev.sh && ./Setup_DebianXfceVNC_PythonDev.sh
License:
CC BY 4.0