无法将 mosquitto 配置文件添加到 ECS 任务:

问题描述 投票:0回答:1

我有一个 mosquitto 代理在 docker 本地计算机上运行,并带有一些配置文件。我用来运行代理的命令如下所示

docker运行-it --name mosquittoBroker -p 1884:1884 -p 1883:1883 -v C:/Users/BadhushaAkhthaar/Documents/conf:/etc/mosquitto 377a70d9c469069f41efb1c21f00b8b3a70da80dd80498039f88 1465d85f0d96

mosquitto.conf 文件位于我本地系统的路径 C:/Users/BadhushaAkhthaar/Documents/conf

在本地系统中运行良好。

我尝试在 AWS ECS 中移动/托管代理,作为一项任务,配置如下

{
"taskDefinitionArn": "arn:aws:ecs:us-east-1:18008000010:task-definition/finch-mosquitto-td:1",
"containerDefinitions": [
    {
        "name": "mosquitto",
        "image": "iegomez/mosquitto-go-auth:latest",
        "cpu": 0,
        "portMappings": [
            {
                "name": "mosquitto-1883-tcp",
                "containerPort": 1883,
                "hostPort": 1883,
                "protocol": "tcp",
                "appProtocol": "http"
            },
            {
                "name": "mosquitto-1884-tcp",
                "containerPort": 1884,
                "hostPort": 1884,
                "protocol": "tcp",
                "appProtocol": "http"
            }
        ],
        "essential": true,
        "environment": [],
        "environmentFiles": [],
        "mountPoints": [
            {
                "sourceVolume": "mosquitto_config",
                "containerPath": "/conf",
                "readOnly": false
            }
        ],
        "volumesFrom": [],
        "ulimits": [],
        "logConfiguration": {
            "logDriver": "awslogs",
            "options": {
                "awslogs-create-group": "true",
                "awslogs-group": "/ecs/finch-mosquitto-td",
                "awslogs-region": "us-east-1",
                "awslogs-stream-prefix": "ecs"
            },
            "secretOptions": []
        }
    }
],
"family": "finch-mosquitto-td",
"taskRoleArn": "arn:aws:iam::18008000010:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::18008000010:role/ecsTaskExecutionRole",
"networkMode": "bridge",
"revision": 1,
"volumes": [
    {
        "name": "mosquitto_config",
        "host": {
            "sourcePath": "/etc/mosquitto"
        }
    }
],
"status": "ACTIVE",
"requiresAttributes": [
    {
        "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
    },
    {
        "name": "ecs.capability.execution-role-awslogs"
    },
    {
        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
    },
    {
        "name": "com.amazonaws.ecs.capability.task-iam-role"
    },
    {
        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
    },
    {
        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
    }
],
"placementConstraints": [],
"compatibilities": [
    "EC2"
],
"requiresCompatibilities": [
    "EC2"
],
"cpu": "512",
"memory": "512",
"runtimePlatform": {
    "cpuArchitecture": "X86_64",
    "operatingSystemFamily": "LINUX"
},
"registeredAt": "2023-08-25T09:16:25.570Z",
"registeredBy": "arn:aws:iam::18008000010:root",
"tags": []
}

我认为上面 JSON 中卷的源路径与 docker 命令中的类似

docker运行-it --name mosquittoBroker -p 1884:1884 -p 1883:1883 -v C:/Users/BadhushaAkhthaar/Documents/conf:/etc/mosquitto 377a70d9c469069f41efb1c21f00b8b3a70da80dd80498 039f881465d85f0d96

我还在主机 EC2 实例的 EBS 卷中创建了一个 /conf/mosquitto.conf 文件。

但仍然出现以下错误

1692960986:错误:无法打开配置文件/etc/mosquitto/mosquitto.conf。

docker amazon-ec2 mqtt amazon-ecs mosquitto
1个回答
0
投票

我的错,我对 mountPoints 和 sourcePaths 感到困惑。我改变了这些值,它工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.