首页 > 其他分享 >docker部署jumpserver

docker部署jumpserver

时间:2023-11-22 15:34:04浏览次数:36  
标签:core 部署 REDIS DB jumpserver docker data PORT

安装docker

版本

$ docker version
Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:07:41 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:07:41 2023
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.24
  GitCommit:        61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc:
  Version:          1.1.9
  GitCommit:        v1.1.9-0-gccaecfc
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ docker compose version
Docker Compose version v2.21.0

安装部署

官方源码库 https://github.com/jumpserver/Dockerfile

相关目录

.
├── config_example.conf
├── db.yml
├── docker-compose-build.yml
├── docker-compose-init-db.yml
├── docker-compose-network.yml
└── docker-compose.yml

修改配置

$ mv config_example.conf .env
$ vim .env
# 版本号可以自己根据项目的版本修改
VERSION=v3.8.2

# 构建参数, 支持 amd64/arm64/loong64
TARGETARCH=amd64

# Compose
COMPOSE_PROJECT_NAME=jms
# COMPOSE_HTTP_TIMEOUT=3600
# DOCKER_CLIENT_TIMEOUT=3600

# 持久化存储
VOLUME_DIR=/data/jumpserver/data

# MySQL 修改为你的外置 **数据库** 地址
DB_HOST=mysql
DB_PORT=3306
DB_USER=root
DB_PASSWORD=xxxxxxxxxxxxxxx
DB_NAME=jumpserver

# Redis 修改为你的外置 **Redis** 地址 这里也是采用容器的方式部署,所以,redis直接使用容器名成 
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=xxxxxxxxxxxxxxx

# Core 修改 SECRET_KEY 和 BOOTSTRAP_TOKEN
SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BOOTSTRAP_TOKEN=xxxxxxxxxxxxxxx
DEBUG=FALSE
LOG_LEVEL=ERROR
DOMAINS=192.168.xxx.xxx

# Web
HTTP_PORT=80
SSH_PORT=2222
MAGNUS_MYSQL_PORT=33061
MAGNUS_MARIADB_PORT=33062
MAGNUS_REDIS_PORT=63790

# Xpack
RDP_PORT=3389
MAGNUS_POSTGRESQL_PORT=54320
MAGNUS_ORACLE_PORTS=30000-30010

##
# SECRET_KEY 保护签名数据的密匙, 首次安装请一定要修改并牢记, 后续升级和迁移不可更改, 否则将导致加密的数据不可解密。
# BOOTSTRAP_TOKEN 为组件认证使用的密钥, 仅组件注册时使用。组件指 koko、guacamole

各资源清单文件

# docker-compose-network.yml
version: '2.4'

networks:
  net:
    enable_ipv6: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.16.238.0/24
          gateway: 172.16.238.1
        - subnet: 2001:1111:1111:1111::/64
          gateway: 2001:1111:1111:1111::1
# docker-compose-init-db.yml
version: '2.4'

services:
  core:
    image: jumpserver/core:${VERSION}
    container_name: jms_core
    tty: true
    command: sleep
    environment:
      SECRET_KEY: $SECRET_KEY
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      DEBUG: $DEBUG
      LOG_LEVEL: $LOG_LEVEL
      DB_HOST: $DB_HOST
      DB_PORT: $DB_PORT
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      REDIS_HOST: $REDIS_HOST
      REDIS_PORT: $REDIS_PORT
      REDIS_PASSWORD: $REDIS_PASSWORD
    volumes:
      - ${VOLUME_DIR}/core/data:/opt/jumpserver/data
      - ${VOLUME_DIR}/core/logs:/opt/jumpserver/logs
    networks:
      - net
# db.yml
---
version: '3'
services:
  mysql:
    image: jumpserver/mariadb:10.6
    container_name: jms_mysql
    restart: always
    command: --character-set-server=utf8 --collation-server=utf8_general_ci
    environment:
      DB_PORT: $DB_PORT
      MARIADB_ROOT_PASSWORD: $DB_PASSWORD
      MARIADB_DATABASE: $DB_NAME
    healthcheck:
      test: "mysql -h127.0.0.1 -P$$DB_PORT -uroot -p$$MARIADB_ROOT_PASSWORD -e 'SHOW DATABASES;'"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 30s
    volumes:
      - ${VOLUME_DIR}/mariadb/data:/var/lib/mysql
    networks:
      - net
  redis:
    image: jumpserver/redis:6.2
    container_name: jms_redis
    restart: always
    command: redis-server --requirepass $REDIS_PASSWORD --loglevel warning --maxmemory-policy allkeys-lru
    ports:
      - ${REDIS_PORT}:6379
    environment:
      TZ: Asia/Shanghai
      REDIS_PORT: $REDIS_PORT
      REDIS_PASSWORD: $REDIS_PASSWORD
    healthcheck:
      test: "redis-cli -h 127.0.0.1 -p $$REDIS_PORT -a $$REDIS_PASSWORD info Replication"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - ${VOLUME_DIR}/redis/data:/data
    networks:
      - net
  core:
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy 
# docker-compose.yml
version: '2.4'
services:
  core:
    image: jumpserver/core:${VERSION}
    container_name: jms_core
    ulimits:
      core: 0
    restart: always
    tty: true
    command: start web
    environment:
      SECRET_KEY: $SECRET_KEY
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      DEBUG: $DEBUG
      LOG_LEVEL: $LOG_LEVEL
      #DOMAINS: $DOMAINS
      DB_HOST: $DB_HOST
      DB_PORT: $DB_PORT
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      REDIS_HOST: $REDIS_HOST
      REDIS_PORT: $REDIS_PORT
      REDIS_PASSWORD: $REDIS_PASSWORD
      MAGNUS_PORT: ${MAGNUS_PORT:-30000-30020}
      DOMAINS: ${DOMAINS:-}
    healthcheck:
      test: "curl -fsL http://localhost:8080/api/health/ > /dev/null"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 90s
    volumes:
      - ${VOLUME_DIR}/core/data:/opt/jumpserver/data
    networks:
      - net

  celery:
    image: jumpserver/core:${VERSION}
    container_name: jms_celery
    ulimits:
      core: 0
    restart: always
    tty: true
    command: start task
    environment:
      SECRET_KEY: $SECRET_KEY
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      DEBUG: $DEBUG
      LOG_LEVEL: $LOG_LEVEL
      DB_HOST: $DB_HOST
      DB_PORT: $DB_PORT
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      REDIS_HOST: $REDIS_HOST
      REDIS_PORT: $REDIS_PORT
      REDIS_PASSWORD: $REDIS_PASSWORD
      MAGNUS_PORT: ${MAGNUS_PORT:-30000-30020}
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "bash /opt/jumpserver/utils/check_celery.sh"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 30s
    volumes:
      - ${VOLUME_DIR}/core/data:/opt/jumpserver/data
    networks:
      - net

  koko:
    image: jumpserver/koko:${VERSION}
    container_name: jms_koko
    ulimits:
      core: 0
    restart: always
    privileged: true
    tty: true
    environment:
      CORE_HOST: http://core:8080
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      LOG_LEVEL: $LOG_LEVEL
      SSHD_PORT: ${SSH_PORT:-2222}
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "curl -fsL http://localhost:5000/koko/health/ > /dev/null"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - ${VOLUME_DIR}/koko/data:/opt/koko/data
    ports:
      - ${SSH_PORT:-2222}:${SSH_PORT}
    networks:
      - net

  lion:
    image: jumpserver/lion:${VERSION}
    container_name: jms_lion
    ulimits:
      core: 0
    restart: always
    tty: true
    environment:
      CORE_HOST: http://core:8080
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      LOG_LEVEL: $LOG_LEVEL
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "curl -fsL http://localhost:8081/lion/health/ > /dev/null"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - ${VOLUME_DIR}/lion/data:/opt/lion/data
    networks:
      - net

  magnus:
    image: jumpserver/magnus:${VERSION}
    container_name: jms_magnus
    ulimits:
      core: 0
    restart: always
    tty: true
    environment:
      CORE_HOST: http://core:8080
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      LOG_LEVEL: $LOG_LEVEL
      MAGNUS_MYSQL_PORT: ${MAGNUS_MYSQL_PORT:-33061}
      MAGNUS_MARIADB_PORT: ${MAGNUS_MARIADB_PORT:-33062}
      MAGNUS_REDIS_PORT: ${MAGNUS_REDIS_PORT:-63790}
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "nc -z 127.0.0.1 33061 || exit 1"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - ${VOLUME_DIR}/magnus/data:/opt/magnus/data
    ports:
      - ${MAGNUS_MYSQL_PORT:-33061}:33061
      - ${MAGNUS_MARIADB_PORT:-33062}:33062
      - ${MAGNUS_REDIS_PORT:-63790}:63790
    networks:
      - net

  chen:
    image: jumpserver/chen:${VERSION}
    container_name: jms_chen
    ulimits:
      core: 0
    restart: always
    tty: true
    environment:
      CORE_HOST: http://core:8080
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      LOG_LEVEL: $LOG_LEVEL
    volumes:
      - ${VOLUME_DIR}/chen/data:/opt/chen/data
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "curl -f 127.0.0.1:8082/chen"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 60s
    networks:
      - net

  kael:
    image: jumpserver/kael:${VERSION}
    container_name: jms_kael
    ulimits:
      core: 0
    restart: always
    tty: true
    environment:
      CORE_HOST: http://core:8080
      BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
      LOG_LEVEL: $LOG_LEVEL
    volumes:
      - ${VOLUME_DIR}/kael/data:/opt/kael/data
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "curl -fsL http://localhost:8083/kael/health/ > /dev/null"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 60s
    networks:
      - net

  web:
    image: jumpserver/web:${VERSION}
    container_name: jms_web
    restart: always
    tty: true
    depends_on:
      core:
        condition: service_healthy
    healthcheck:
      test: "curl -fsL http://localhost/ > /dev/null"
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - ${VOLUME_DIR}/core/data:/opt/jumpserver/data
      - ${VOLUME_DIR}/nginx/data/logs:/var/log/nginx
    ports:
      - ${HTTP_PORT:-80}:${HTTP_PORT:-80}
    networks:
      - net

部署

docker compose -f docker-compose-network.yml -f docker-compose-init-db.yml -f db.yml up -d
# 查看日志等待稳定
# 导入数据库表数据
docker exec -i jms_core bash -c './jms upgrade_db'
# 等待结束
# 起各组件容器
docker compose -f docker-compose-network.yml -f docker-compose.yml up -d

至此,容器化部署完成

浏览器访问 http://192.168.140.28

初始化密码是admin/admin

初次进入需要修改密码

标签:core,部署,REDIS,DB,jumpserver,docker,data,PORT
From: https://www.cnblogs.com/guangdelw/p/17849124.html

相关文章

  • filerun docker方式安装(debian arm64, tinkerboard2s类似树莓派)
    启动mysqldockerrun-p3366:3306--namemysql57--privileged=true-eMYSQL_ROOT_PASSWORD=12345-v/mnt/docker/varlibmysql:/var/lib/mysql-dliupeng0518/mysql:5.7-arm64#redis命令dockerrun-itd--nameredis--privileged=true-p6380:6379redis--requir......
  • docker安装
     一、Dockerdesktop安装(1)首先要开启Hyper-V,开启操作参照https://blog.csdn.net/qq_44368508/article/details/126601570(2)DockerDesktop官方下载地址: https://docs.docker.com/desktop/install/windows-install/会很慢,直接找到其他下载地址,下载DockerDesktop4.24.1......
  • docker问题:overlay2占用磁盘空间过大
     实践:dockersystemprune-a-f   [root@imagedocker]#du--max-depth=1-h4.0K./swarm4.0K./containers4.0K./trust138M./image16K./plugins4.0K./tmp51M./volumes74G./overlay296K./network19M./buildkit4.0K./ru......
  • Docker部署phpMyAdmin
    一、简介phpMyAdmin是众多MySQL图形化管理工具中使用最为广泛的一种,是一款使用PHP开发的基于B/S模式的MySQL客户端软件,该工具是基于Web跨平台的管理程序,并且支持简体中文,用户可以在官网上下载最新版本的。phpMyAdmin为Web开发人员提供了类似Access,SQLServer的图形化......
  • tomcat 安装部署
    1.下载安装包wgethttps://dlcdn.apache.org/tomcat/tomcat-10/v10.1.16/bin/apache-tomcat-10.1.16.tar.gzwgethttps://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz2.解压并修改目录tar-zxvf apache-tomcat-10.1.16.tar.gztar-zxvf jdk-17_linux-x64_bi......
  • docker 部署redis
     OKdockerrun-d--privileged=true--restart=always-p6379:6379-v/usr/local/docker/redis/6379.conf:/etc/redis/redis.conf-v/usr/local/docker/redis/data6379:/data--nameredis6379redis:7.0.5redis-server/etc/redis/redis.confdockerrun-d--privilege......
  • centos修改docker容器的默认地址
    一、需求1.1什么是docker与docker的特点Docker是一种开源容器化平台,它允许开发者将应用程序及其依赖打包成一个容器,这个容器可以在任何支持Docker的环境中运行。容器化是一种轻量级的虚拟化技术,与传统的虚拟机(VM)技术相比,具有几个显著的优势:资源效率Docker:容器直接运行......
  • docker和docker-compose生产的容器,不在同一个网段,解决方式
    在实际项目中,使用dockerrunxxXx 和docker-composeup-d不在同一个网段,一个是默认是172.17.x.x, 另一个是172.19.x.x。为解决这个问题需要自定义一个网络,我命名为“my-bridge”首先熟悉几条命令:dockernetworkls或者dockernetworklist 查看当前的docker网络......
  • 使用docker 搭建xtrabackup服务,实现mysql全量和增量备份
    根据前面的mysql备份调研得知,mysql的备份重头戏就是xtrabackup,mysqldump只能算开胃菜本篇就着重讨论下xtrabackup的使用,由于考虑到维持虚拟机环境的整洁,和搭建使用的通用和便利性,这里选择基于docker环境使用照惯例,学习任何一个工具最佳途径就是研读官方文档,这里贴出官方文档:http......
  • 使用docker 搭建xtrabackup服务,实现mysql全量和增量备份
    mysql数据库的备份是运维的重中之重,是保障服务灾难恢复的最后一道屏障在我的构想里,一个完备的mysql容灾体系应该包括高可用架构和一套基础的数据库备份方案高可用架构:MM+ Keepalived,PXC(PerconaXtraDBCluster)或者GR(GroupReplication),来保证故障恢复,并附带一个延迟备库(延迟1......