coteerratu commited on
Commit
4d89218
·
verified ·
1 Parent(s): 1c9c3dc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -9
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
- # 使用Ubuntu作为基础镜像
2
  FROM ubuntu:latest
3
 
4
- # 更新包列表并安装必要的软件包
5
  RUN apt-get update && apt-get install -y \
6
  bash \
7
  wget \
@@ -10,29 +10,32 @@ RUN apt-get update && apt-get install -y \
10
 
11
  RUN apt-get clean && rm -rf /var/lib/apt/lists/*
12
 
13
- # 创建 /data 目录并赋予用户 1001 权限
 
 
 
14
  RUN mkdir -p /data && chown -R 1001:1001 /data
15
 
16
- # 下载并安装 gotty
17
  RUN wget -O gotty.tar.gz https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz \
18
  && tar -xzvf gotty.tar.gz -C /usr/local/bin/ \
19
  && chmod +x /usr/local/bin/gotty \
20
  && rm gotty.tar.gz
21
 
22
- # 创建用户 1001 并设置工作目录
23
  RUN useradd -u 1001 -d /data user1001 \
24
  && echo 'user1001 ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/user1001 \
25
  && chmod 0440 /etc/sudoers.d/user1001
26
 
27
- # 切换到用户 1001 并设置工作目录
28
  USER 1001
29
  WORKDIR /data
30
 
31
- # 创建 .bashrc 文件并设置 PS1 环境变量
32
  RUN echo 'PS1="online-terminal:\\w\\$ "' > /data/.bashrc
33
 
34
- # 暴露端口
35
  EXPOSE 8080
36
 
37
- # 使用 gotty 运行 bash,并修改 PS1 环境变量
38
  CMD ["gotty", "--permit-write", "--port", "3000", "--permit-arguments", "/bin/bash", "--rcfile", "/data/.bashrc"]
 
1
+ # Use Ubuntu as the base image
2
  FROM ubuntu:latest
3
 
4
+ # Update package lists and install necessary packages
5
  RUN apt-get update && apt-get install -y \
6
  bash \
7
  wget \
 
10
 
11
  RUN apt-get clean && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Disable 'no new privileges' flag
14
+ RUN echo 'Defaults !sysctl,!snap' > /etc/sudoers.d/no-new-privileges
15
+
16
+ # Create /data directory and give permission to user 1001
17
  RUN mkdir -p /data && chown -R 1001:1001 /data
18
 
19
+ # Download and install gotty
20
  RUN wget -O gotty.tar.gz https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz \
21
  && tar -xzvf gotty.tar.gz -C /usr/local/bin/ \
22
  && chmod +x /usr/local/bin/gotty \
23
  && rm gotty.tar.gz
24
 
25
+ # Create user 1001 and set working directory
26
  RUN useradd -u 1001 -d /data user1001 \
27
  && echo 'user1001 ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/user1001 \
28
  && chmod 0440 /etc/sudoers.d/user1001
29
 
30
+ # Switch to user 1001 and set working directory
31
  USER 1001
32
  WORKDIR /data
33
 
34
+ # Create .bashrc file and set PS1 environment variable
35
  RUN echo 'PS1="online-terminal:\\w\\$ "' > /data/.bashrc
36
 
37
+ # Expose port
38
  EXPOSE 8080
39
 
40
+ # Use gotty to run bash and modify PS1 environment variable
41
  CMD ["gotty", "--permit-write", "--port", "3000", "--permit-arguments", "/bin/bash", "--rcfile", "/data/.bashrc"]