一、检查服务器系统版本
[root@server001 webssh]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
二、检查docker状态
[root@server001 webssh]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-11-06 06:02:26 CST; 1 weeks 5 days ago
Docs: https://docs.docker.com
Main PID: 9869 (dockerd)
Tasks: 55
Memory: 3.4G
CGroup: /system.slice/docker.service
├─ 9869 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─ 88493 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3222 -container-ip 192.168.80.2 -container-port 5032
├─ 88500 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3222 -container-ip 192.168.80.2 -container-port 5032
├─ 91124 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 10000 -container-ip 172.17.0.3 -container-port 10000
├─ 91130 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 10000 -container-ip 172.17.0.3 -container-port 10000
├─116625 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8765 -container-ip 172.17.0.2 -container-port 80
└─116630 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8765 -container-ip 172.17.0.2 -container-port 80
Nov 15 13:06:16 server001 dockerd[9869]: time="2022-11-15T13:06:16.705110008+08:00" level=warning msg="Image docker.io/thklein/laverna:la...ema-v1/"
Nov 15 13:13:38 server001 dockerd[9869]: time="2022-11-15T13:13:38.719013168+08:00" level=info msg="Container failed to exit within 10s o...c1e1c6f9
Nov 15 13:13:38 server001 dockerd[9869]: time="2022-11-15T13:13:38.760070499+08:00" level=info msg="ignoring event" container=501164f94c0...kDelete"
Nov 15 13:14:12 server001 dockerd[9869]: time="2022-11-15T13:14:12.896232564+08:00" level=warning msg="Failed to allocate and map port 80... in use"
Nov 15 13:14:12 server001 dockerd[9869]: time="2022-11-15T13:14:12.922826590+08:00" level=error msg="539e0a34e6e5fdb064da0cff34c6ac458fbe...ntainer"
Nov 15 13:14:12 server001 dockerd[9869]: time="2022-11-15T13:14:12.922892644+08:00" level=error msg="Handler for POST /v1.41/containers/539e0a34e...
Nov 18 15:04:59 server001 dockerd[9869]: time="2022-11-18T15:04:59.448235074+08:00" level=info msg="Attempting next endpoint for pull aft...unknown"
Nov 18 15:09:28 server001 dockerd[9869]: time="2022-11-18T15:09:28.678785052+08:00" level=error msg="Not continuing with pull after error...anceled"
Nov 18 15:45:58 server001 dockerd[9869]: time="2022-11-18T15:45:58.807424181+08:00" level=info msg="Container failed to exit within 10s o...1f9adbeb
Nov 18 15:46:00 server001 dockerd[9869]: time="2022-11-18T15:46:00.385045862+08:00" level=info msg="ignoring event" container=16539a40754...kDelete"
Hint: Some lines were ellipsized, use -l to show in full.
三、下载webssh2镜像
[root@server001 webssh]# docker pull lihaixin/webssh2:ssh
Unable to find image 'lihaixin/webssh2:ssh' locally
ssh: Pulling from lihaixin/webssh2
ca3cd42a7c95: Pull complete
71cb5a638638: Pull complete
2033bc407fc5: Pull complete
Digest: sha256:4055605cdcbcae6a76326962a0413d254beee60155d72f373f21aac61f96e09e
Status: Downloaded newer image for lihaixin/webssh2:ssh
四、创建webssh2容器
1.创建webssh2容器
docker run -d \
-p 5032:5032 \
--restart always \
--name webssh \
lihaixin/webssh2:ssh
2.查看webssh2状态
[root@server001 webssh]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
508a058faaf3 lihaixin/webssh2:ssh "/webssh" About a minute ago Up About a minute 0.0.0.0:5032->5032/tcp, :::5032->5032/tcp webssh
3.查看容器运行日志
[root@server001 webssh]# docker logs webssh
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET / --> main.staticRouter.func2 (4 handlers)
[GIN-debug] GET /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)
[GIN-debug] HEAD /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)
[GIN-debug] GET /term --> main.main.func1 (4 handlers)
[GIN-debug] GET /check --> main.main.func2 (4 handlers)
[GIN-debug] GET /file/list --> main.main.func3 (4 handlers)
[GIN-debug] GET /file/download --> main.main.func4 (4 handlers)
[GIN-debug] POST /file/upload --> main.main.func5 (4 handlers)
[GIN-debug] Listening and serving HTTP on :5032
五、访问webssh2