尝试使用 elasticbeanstalk 和 eb cli 部署 AWS 多容器时出现 CannotPullContainerError

尝试使用 elasticbeanstalk 和 eb cli 部署 AWS 多容器时出现 CannotPullContainerError

我一直在尝试使用ebcli 将一个简单的 docker 镜像部署到 AWS ElasticBeanstalk,但由于以下错误,我无法在 ECS 中启动 docker 服务:

无效的引用格式:存储库名称必须为小写

我的Dockerrun.aws.json文件:

{
  "AWSEBDockerrunVersion": 2,
  "containerDefinitions": [
    {
      "name": "ipsec-vpn-server",
      "image": "hwdsl2/ipsec-vpn-server:latest",
      "essential": true,
      "memory": 128,
      "portMappings": [
        {
          "hostPort": 500,
          "containerPort": 500
        },
        {
          "hostPort": 4500,
          "containerPort": 4500
        }
      ]
    }
  ]
}

我的.ebignore

# Only keep Dockerrun.aws.json
*
!Dockerrun.aws.json

我将这个AWSElasticBeanstalkMulticontainerDocker角色附加到aws-elasticbeanstalk-service-role

aws --profile my-profile-name \
iam attach-role-policy \
policy-arn arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker \
--role-name aws-elasticbeanstalk-service-role

aws-elasticbeanstalk-service-role 中的 AWSElasticBeanstalkMulticontainerDocker 策略

我创建了这样的 aws eb 环境:

export VPN_USER="some_secret_user"
export VPN_PASSWORD="some_secret_password"    
export VPN_IPSEC_PSK="some_secret_ipsec_psk"

eb create vpn-example \
--profile my-profile-name \
--region us-east-1 \
--platform multi-container-docker-17.09.1-ce-\(generic\) \
--envvars VPN_USER=${VPN_USER} \
--envvars VPN_PASSWORD=${VPN_PASSWORD} \
--envvars VPN_IPSEC_PSK=${VPN_IPSEC_PSK} \
--cname some-vpn-example-domain

环境确实创建正确,但正如您所见,它并不健康;)

eb 环境

环境创建运行了一段时间,创建了负载平衡器等。但是在 ECS 仪表板中尝试启动任务多次后,一段时间后失败:

ecs 集群

当单击单个任务时,我看到以下内容: 无效的引用格式:存储库名称必须为小写

地位:

已停止(CannotPullContainerError:API 错误(400):无效)

详细状态原因:

CannotPullContainerError:API 错误(400):引用格式无效:存储库名称必须小写

最新事件在 Elastic beanstalk 环境中显示以下警告:

环境健康状态已从“降级”转为“严重”。所有实例上的命令均失败。所有实例的 ELB 健康状态均失败或不可用。

eb logs根本没有输出。

containerDefinitions我在's中没有使用任何大写字母image。我发现的唯一奇怪的东西是Image任务中显示Dockerrun.aws.json我期望它所在的列hwdsl2/ipsec-vpn-server(我认为)。

我还以为这应该是一项服务而不是一项任务。任何帮助都将不胜感激。

我似乎找不到读取日志的方法。我从头开始再次尝试,eb create命令的日志如下:

WARNING: The Multi-container Docker platform requires additional ECS permissions. Add the permissions to the aws-elasticbeanstalk-ec2-role or use your own instance profile by typing "-ip {profile-name}".
For more information see: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html#create_deploy_docker_ecs_role
Creating application version archive "app-xxxx-xxxxxx_xxxxxx".
Uploading example-vpn/app-xxxx-xxxxxx_xxxxxx.zip to S3. This may take a while.
Upload Complete.
Environment details for: vpn-dev-01
  Application name: example-vpn
  Region: us-east-1
  Deployed Version: app-xxxx-xxxxxx_xxxxxx
  Environment ID: e-mtwbaums2n
  Platform: arn:aws:elasticbeanstalk:us-east-1::platform/Multi-container Docker running on 64bit Amazon Linux/2.9.0
  Tier: WebServer-Standard-1.0
  CNAME: example-vpn-SNIP.us-east-1.elasticbeanstalk.com
  Updated: 2018-03-22 18:55:03.173000+00:00
Printing Status:
INFO: createEnvironment is starting.
INFO: Using elasticbeanstalk-us-east-1-xxxxxxxxxxxx as Amazon S3 storage bucket for environment data.
INFO: Created security group named: sg-SNIP
INFO: Created security group named: awseb-e-SNIP
INFO: Created load balancer named: awseb-e-SNIP
INFO: Created Auto Scaling launch configuration named: awseb-e-SNIP
INFO: Created Auto Scaling group named: awseb-SNIP
INFO: Waiting for EC2 instances to launch. This may take a few minutes.
INFO: Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-1:SNIP
INFO: Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-1:SNIP
INFO: Created CloudWatch alarm named: awseb-e-SNIP
INFO: Created CloudWatch alarm named: awseb-e-SNIP
ERROR: Failed to start ECS task: arn:aws:ecs:us-east-1:xxxxxxxxxxxx:task/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is STOPPED.
ERROR: ECS task stopped due to: Essential container in task exited. (ipsec-vpn-server: )
ERROR: Failed to start ECS task: arn:aws:ecs:us-east-1:xxxxxxxxxxxx:task/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is STOPPED.
ERROR: Failed to start ECS task after retrying 2 times.
ERROR: [Instance: i-xxxxxxxxxxxxxxxxx] Command failed on instance. Return code: 1 Output: trying 2 times.' --severity ERROR
+ exit 1.
Hook /opt/elasticbeanstalk/hooks/appdeploy/enact/03start-task.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

我再次尝试使用不同的docker镜像nginx:latest,服务启动了,所以我遇到的问题是hwdsl2/ipsec-vpn-server:latest直接。我再次尝试,但在本地:

docker pull hwdsl2/ipsec-vpn-server:latest
eb local run --debug

它向我显示了错误:

ipsecvpnserver_1 | Error: This Docker image must be run in privileged mode.
ipsecvpnserver_1 |
ipsecvpnserver_1 | For detailed instructions, please visit:
ipsecvpnserver_1 | https://github.com/hwdsl2/docker-ipsec-vpn-server
ipsecvpnserver_1 |
elasticbeanstalk_ipsecvpnserver_1 exited with code 1

elasticbeanstalk 中的日志并不总是易于阅读。我将其添加到Dockerrun.aws.json

"privileged": true,

现在,它在运行时确实可以在本地成功启动eb local run,但在云端仍然失败。

我已经创建hwdsl2/docker-ipsec-vpn-server 上的问题

相关内容