linux 如何设置MLflow Authentication docker

0yg35tkg  于 2023-11-17  发布在  Linux
关注(0)|答案(1)|浏览(101)

我想将MLflow身份验证配置为rw per user。我的docker文件如下所示:https://pastebin.com/yD9ACWzp
在nginx环境中,我添加了
第一个月
- MLFLOW_TRACKING_PASSWORD=xxxxxxxxxx
我启用了身份验证,但现在无法登录
非常感谢您的意见和建议.

fhity93d

fhity93d1#

当我阅读MLflow认证文档时,我认为你可以在Docker Compose的应用服务中添加一个环境变量,如下所示:

environment:
  - BACKEND=postgresql://${DB_USER:-postgres}@${DB_SERVER:-db}:${DB_PORT:-5432}/${DB_NAME:-mlflow}
  - ARTIFACTS=/storage/mlruns  # in-container path to filestore in filesys
  - MLFLOW_TRACKING_USERNAME=administrator
  - MLFLOW_TRACKING_PASSWORD=YourPassword

字符串
以下是完整的docker-compose.yaml:

version: '3.3'
 
services:
    db:
        restart: always
        image: postgres:13
        container_name: mlflow_db
        expose:
            - ${DB_PORT:-5432}
        # networks:
        #     - backend
        environment:
            # - MUID=$UID
            #  - MGID=$GID
          - POSTGRES_DB=${DB_NAME:-mlflow}
          - POSTGRES_USER=${DB_USER:-postgres}
          - POSTGRES_PASSWORD_FILE=/run/secrets/pg_admin_pw
        secrets:
            - pg_admin_pw
        volumes:
            - datapg_vol:/var/lib/postgresql/data
 
    app:
        restart: always
        build: ./mlflow
        image: mlflow_server
        container_name: mlflow_server
        expose:
            - 5001
        # networks:
        #     - frontend
        #     - backend
        environment:
          - BACKEND=postgresql://${DB_USER:-postgres}@${DB_SERVER:-db}:${DB_PORT:-5432}/${DB_NAME:-mlflow}
          - ARTIFACTS=/storage/mlruns  # in-container path to filestore in filesys
          - MLFLOW_TRACKING_USERNAME=administrator
          - MLFLOW_TRACKING_PASSWORD=YourPassword
          # For artifact store in AWS S3 (uses boto that was installed in container):
          # Commment out ARTIFACTS line above and instead use:
          #  - ARTIFACTS="s3://mlflow_bucket/my_mlflow_dir/"
          #  - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
          #  - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
          #  - AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
        volumes:
            - ${FILESTORE:-/storage/mlruns}:/storage/mlruns  # can comment out this line if using S3
            - ${PGPASS:-~/.pgpass}:/root/.pgpass  # provides the pw for BACKEND database
            - condaenv_vol:/opt/conda  # provides continuity/speed when looping runs with same container
        command:
            - sh    # (sh allows for var substitution of BACKEND and ARTIFACTS)
            - -c
            - mlflow server
                --port 5001
                --host 0.0.0.0
                --backend-store-uri $${BACKEND}
                --default-artifact-root $${ARTIFACTS}
                --app-name basic-auth
        # depends_on:
        #     - db
 
    nginx:
        restart: always
        build: ./nginx
        image: mlflow_nginx
        container_name: mlflow_nginx
        ports:
            - "${MLFLOW_PORT:-5000}:80"
        environment:
          - MLFLOW_TRACKING_USERNAME=administrator
          - MLFLOW_TRACKING_PASSWORD=xxxxxxxxxx
            #volumes:
            #- nginx_vol:/etc/nginx
        # networks:
        #     - frontend
        depends_on:
            - app
 
# networks:
#     frontend:
#         driver: bridge
#     backend:
#         driver: bridge
 
secrets:
    pg_admin_pw:
        file: ~/.pgadminpw
 
volumes:
    mlruns_vol:
    datapg_vol:
    condaenv_vol:


希望对你有帮助!如果你遇到其他问题,我很乐意帮助你!

相关问题