一 、docker 部署 webtop-ubuntu 桌面

原项目仓库地址:https://docs.linuxserver.io/images/docker-webtop

后台地址:http://10.10.10.251:3006

1、创建 docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
mkdir -p /vol1/1000/compose/webtop-ubuntu && \
cd /vol1/1000/compose/webtop-ubuntu && \
touch docker-compose.yml && \
cat > docker-compose.yml <<'EOF'
services:
webtop-ubuntu:
image: lscr.io/linuxserver/webtop:ubuntu-kde
container_name: webtop-ubuntu
security_opt:
- seccomp:unconfined
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- SUBFOLDER=/
- TITLE=Webtop
- CUSTOM_USER=admin # 替换为实际用户名
- PASSWORD=your_password # 替换为实际密码
- LC_ALL=zh_CN.UTF-8
ports:
- 3006:3000
volumes:
- ./config:/config
- /var/run/docker.sock:/var/run/docker.sock
devices:
- /dev/dri:/dev/dri
shm_size: 2gb
restart: unless-stopped

## 修改更多镜像系统
## lscr.io/linuxserver/webtop:latest
## lscr.io/linuxserver/webtop:ubuntu-xfce
## lscr.io/linuxserver/webtop:fedora-xfce
## lscr.io/linuxserver/webtop:arch-xfce
## lscr.io/linuxserver/webtop:debian-xfce
## 官方地址:
## https://docs.linuxserver.io/images/docker-webtop
EOF

docker-compose up -d

2 、拉取并运行

1
2
cd /vol1/1000/compose/webtop-ubuntu && \
docker-compose up -d

3 、停止并删除

1
2
cd /vol1/1000/compose/webtop-ubuntu && \
docker-compose down

4 、拉取镜像

1
2
cd /vol1/1000/compose/webtop-ubuntu && \
docker-compose pull

5 、容器升级

1
2
3
4
5
cd /vol1/1000/compose/webtop-ubuntu && \
docker-compose down && \
docker-compose pull && \
docker-compose up -d && \
docker image prune -f

6 、查看容器日志

1
docker logs webtop-ubuntu

二 、容器维护命令

1 、查看所有运行容器的名称

1
docker ps -a --format "{{.Names}}"

2 、停止 webtop-ubuntu 容器

1
docker stop webtop-ubuntu

3 、启动 webtop-ubuntu 容器

1
docker start webtop-ubuntu

4 、重启 webtop-ubuntu 容器

1
docker restart webtop-ubuntu

5 、进入 webtop-ubuntu 容器

1
2
3
## Ctrl+D 退出容器
## docker exec -it webtop-ubuntu sh
docker exec -it webtop-ubuntu bash

6 、查看 webtop-ubuntu 配置文件

1
cat /vol1/1000/compose/webtop-ubuntu/docker-compose.yml

Nginx 配置

后台地址:https://ubuntu.example.com:666

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
mkdir -pm 755 /etc/nginx/conf.d && \
touch /etc/nginx/conf.d/webtop-ubuntu.conf && \
cat <<'EOF' | sed '1!{/^[[:space:]]*#/d;/^[[:space:]]*$/d}' > /etc/nginx/conf.d/webtop-ubuntu.conf
## nginx 反向代理: webtop-ubuntu 桌面
server {
listen 666 ssl;
listen [::]:666 ssl;
server_name ubuntu.example.com;
ssl_certificate /etc/nginx/keyfile/cert.pem;
ssl_certificate_key /etc/nginx/keyfile/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff always;
add_header X-Frame-Options "SAMEORIGIN" always;
sendfile on;
tcp_nopush on;
client_max_body_size 10G;
error_page 404 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location / {
proxy_pass http://10.10.10.251:3006;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 16k;
proxy_busy_buffers_size 24k;
proxy_max_temp_file_size 0;
}
}
EOF

sudo systemctl restart nginx