docker compose部署netbox

文章详细描述了如何使用DockerCompose版本3.4来配置NetBox服务,包括镜像选择、依赖关系、健康检查、数据卷以及端口映射,同时提及了环境变量设置和数据库性能对启动时间的影响。
摘要由CSDN通过智能技术生成

docker compose:

version: '3.4'
services:
  netbox: &netbox
    image: docker.io/netboxcommunity/netbox:${VERSION-v3.7-2.8.0}
    depends_on:
    - postgres
    - redis
    - redis-cache
    env_file: env/netbox.env
    user: 'unit:root'
    healthcheck:
      start_period: 60s
      timeout: 3s
      interval: 15s
      test: "curl -f http://localhost:8080/api/ || exit 1"
    volumes:
    - ./configuration:/etc/netbox/config:z,ro
    - netbox-media-files:/opt/netbox/netbox/media:rw
    - netbox-reports-files:/opt/netbox/netbox/reports:rw
    - netbox-scripts-files:/opt/netbox/netbox/scripts:rw
  netbox-worker:
    <<: *netbox
    depends_on:
      netbox:
        condition: service_healthy
    command:
    - /opt/netbox/venv/bin/python
    - /opt/netbox/netbox/manage.py
    - rqworker
    healthcheck:
      start_period: 20s
      timeout: 3s
      interval: 15s
      test: "ps -aux | grep -v grep | grep -q rqworker || exit 1"
  netbox-housekeeping:
    <<: *netbox
    depends_on:
      netbox:
        condition: service_healthy
    command:
    - /opt/netbox/housekeeping.sh
    healthcheck:
      start_period: 20s
      timeout: 3s
      interval: 15s
      test: "ps -aux | grep -v grep | grep -q housekeeping || exit 1"

  # postgres
  postgres:
    image: docker.io/postgres:16-alpine
    env_file: env/postgres.env
    volumes:
    - netbox-postgres-data:/var/lib/postgresql/data

  # redis
  redis:
    image: docker.io/redis:7-alpine
    command:
    - sh
    - -c # this is to evaluate the $REDIS_PASSWORD from the env
    - redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
    env_file: env/redis.env
    volumes:
    - netbox-redis-data:/data
  redis-cache:
    image: docker.io/redis:7-alpine
    command:
    - sh
    - -c # this is to evaluate the $REDIS_PASSWORD from the env
    - redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
    env_file: env/redis-cache.env
    volumes:
    - netbox-redis-cache-data:/data

volumes:
  netbox-media-files:
    driver: local
  netbox-postgres-data:
    driver: local
  netbox-redis-cache-data:
    driver: local
  netbox-redis-data:
    driver: local
  netbox-reports-files:
    driver: local
  netbox-scripts-files:
    driver: local

配置 NetBox 的服务端口

version: '3.4'
services:
  netbox:
    ports:
      - "8000:8080"
    # If you want the Nginx unit status page visible from the
    # outside of the container add the following port mapping:
    # - "8001:8081"
    # healthcheck:
      # Time for which the health check can fail after the container is started.
      # This depends mostly on the performance of your database. On the first start,
      # when all tables need to be created the start_period should be higher than on
      # subsequent starts. For the first start after major version upgrades of NetBox
      # the start_period might also need to be set higher.
      # Default value in our docker-compose.yml is 60s
      # start_period: 90s
    # environment:
      # SKIP_SUPERUSER: "false"
      # SUPERUSER_API_TOKEN: ""
      # SUPERUSER_EMAIL: ""
      # SUPERUSER_NAME: ""
      # SUPERUSER_PASSWORD: ""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值