ubuntu镜像制作

实现步骤:

  1. 基础镜像:ubuntu:18.04
  2. python版本:python3.8.8
  3. jupyter安装
  4. ssh服务
  5. xface4实现图形界面
  6. tigervncserver实现远程连接
  7. novnc实现web远程
  8. supervisor实现服务进程自动拉起

 

docker run -itd --name myos ubuntu:18.04
docker exec -it myos bash
apt update


#安装python3.8.8
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev liblzma-dev tk-dev libdb-dev
wget https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tgz
tar -xzvf Python-3.8.8.tgz
cd Python-3.8.8
./configure --enable-optimizations
make -j 4  
make altinstall
cp /usr/local/bin/python3.8 /usr/bin/python3


#安装ssh
apt install -y openssh-server
vim /etc/ssh/sshd_config
  Port 22  # 确认端口号
  PermitRootLogin yes  # 如果你需要 root 用户登录
  PasswordAuthentication yes  # 如果使用密码进行身份验证

#安装xface4
apt install xfce4 xfce4-terminal
apt install -y tigervnc-standalone-server
vncserver :1 -localhost no -geometry 1024x768 -SecurityTypes None --I-KNOW-THIS-IS-INSECURE


#安装novnc
apt-get install -y git
git clone https://github.com/novnc/noVNC.git /root/noVNC
cd /root/noVNC
./utils/launch.sh --vnc localhost:5901 --listen 8080
update-alternatives --config x-terminal-emulator


#安装jupyter
pip3.8 install jupyter
jupyter notebook --ip=0.0.0.0 --port=8080 --allow-root


#安装supervisor
apt install supervisor
vim /etc/supervisor/supervisord.conf 
  [supervisord]
  nodaemon=true 
  user=root


  [program:ssh]
  command=service ssh start
  autostart=true
  autorestart=true



  [program:xface]
  command=/bin/bash -c "rm -rf /tmp/.X1-lock && rm -rf /tmp/.X11-unix/ && export USER=root && tigervncserver -localhost no -SecurityTypes=none -geometry 1080x720 -depth 24 --I-KNOW-THIS-IS-INSECURE :1"
  autostart=true
  autorestart=true


  [program:novnc]
  command=/bin/bash -c "/root/noVNC/utils/novnc_proxy --vnc localhost:5901 --listen 6080"
  autostart=true
  autorestart=true

  [program:jupyter]
  command=jupyter notebook --ip=0.0.0.0 --port=8080 --allow-root
  autostart=true
  autorestart=true

#制作镜像
docker commit -c "CMD [\"supervisord\", \"-c\", \"/etc/supervisor/supervisord.conf\"]" myos myos:v1

 

posted @ 2023-12-21 18:27  力王7314  阅读(34)  评论(0编辑  收藏  举报