docker-compose.yml 设置

docker-compose.yml 设置,第1张

docker-compose.yml 设置 yml 样例
# yaml 配置实例
version: '3'
services:
  sts:
    image: faiss:dev
    runtime: nvidia
    environment:
      - NVIDIA_VISIBLE_DEVICES=all  # 可调用所有GPU
      - LANG=C.UTF-8  # 支持中文
    ports:
      - 5500:5500  # 端口设置,docker外部可访问 
    volumes:
      - local_path/code:docker_path/code 
      - local_path/logs:docker_path/logs  # for python logging output
    command: bash
    stdin_open: true
    tty: true
    depends_on:  # 依赖的container
      - mongo
      - es
      - arango
  mongo:
    image: "mongo:latest"
    command: mongod --auth
    environment:
      - MONGO_INITDB_ROOT_USERNAME=usr      # 初始化管理员用户名和密码
      - MONGO_INITDB_ROOT_PASSWORD=pwd
    tty: true
  es:
    image: "elasticsearch:7.13.4"
    expose:
        - '9200'  # 设置端口,只支持docker compose内部调用
        - '9300'
    environment: 
        - "discovery.type=single-node"
        - "ELASTIC_PASSWORD=pwd"    # 设置密码
        - "xpack.security.enabled=true"   # 打开密码验证
    volumes:
        - local_path/elasticsearch_data:/usr/share/elasticsearch/data
    command:
      - /bin/bash
      - -c
      - |
        chmod 777 /tmp
        chown -R 1000:0 /usr/share/elasticsearch/
        sh /usr/local/bin/docker-entrypoint.sh
  arango:
    image: "arangodb:3.7"
    restart: always
    environment:
      ARANGO_ROOT_PASSWORD: pwd
    expose:
      - '8529'
    volumes:
      - local/arangodb_data:/var/lib/arangodb3

  • 问题:docker-compose启动elasticsearch镜像报错AccessDeniedException: /tmp/elasticsearch

    • 方法1: 如果有sudo权限
      1. 创建本地文件夹local_path/elasticsearch_data
      2. chmod -R 777 local_path/elasticsearch_data
    • 方法2: 如果没有sudo权限:
      1. 创建本地文件夹local_path/elasticsearch_data
      2. 在docker内启动elasticsearch前,先进入docker 赋予权限
      - /bin/bash
      - -c
      - |
        chmod 777 /tmp
        chown -R 1000:0 /usr/share/elasticsearch/
        sh /usr/local/bin/docker-entrypoint.sh
docker-compose 常用命令
docker-compose ps  # 查看正在运行的容器
docker-compose logs  # 查看日志
docker-compose up -d # 后台启动docker-compose
docker-compose stop  停止docker-compose
docker-compose down  # 停止docker-compose并删除容器
docker-compose exec container_name bash  # 进入容器

参考链接:https://blog.csdn.net/aodamao/article/details/117039438

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4666552.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-06
下一篇 2022-11-06

发表评论

登录后才能评论

评论列表(0条)

保存