AWS ECS上的Docker容器始终显示已停止

时间:2019-04-02 08:40:28

标签: linux amazon-web-services symfony docker docker-compose

我正在使用CodePiepline建立新的AWS ECS集群。我正在关注以下文档: AWS ECSblog

这是我的docker-compose.yaml

version: "3.0"
services:

    mariadb:
      image: mariadb:10.4
      working_dir: /application
      volumes:
        - .:/application
      environment:
        - MYSQL_ROOT_PASSWORD=123
        - MYSQL_DATABASE=db
        - MYSQL_USER=db
        - MYSQL_PASSWORD=123
      ports:
        - "8003:3306"

    webserver:
      image: nginx:alpine
      working_dir: /application
      volumes:
          - .:/application
          - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
       - "80:80"
       - "443:443"

    php-fpm:
      build: phpdocker/php-fpm
      working_dir: /application
      volumes:
        - .:/application
        - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini

我按照博客教程中提到的步骤进行操作,当我执行以下步骤时,我得到的输出与博客文章中提到的完全相同

$ ecs-cli compose up --cluster xyz --cluster-config xyz --force-update
INFO[0000] Using ECS task definition                     TaskDefinition="xyz-core:1"
INFO[0000] Starting container...                         container=ea894de8-0c31-4879-90ee-e39909f423a5/webserver
INFO[0000] Starting container...                         container=ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm
INFO[0000] Starting container...                         container=ea894de8-0c31-4879-90ee-e39909f423a5/mariadb
INFO[0000] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/mariadb desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0000] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/webserver desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0000] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0012] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/mariadb desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0012] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/webserver desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0012] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0024] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/mariadb desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0024] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/webserver desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0024] Describe ECS container status                 container=ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm desiredStatus=RUNNING lastStatus=PENDING taskDefinition="xyz-core:1"
INFO[0036] Stopped container...                          container=ea894de8-0c31-4879-90ee-e39909f423a5/mariadb desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="xyz-core:1"
INFO[0036] Stopped container...                          container=ea894de8-0c31-4879-90ee-e39909f423a5/webserver desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="xyz-core:1"
INFO[0036] Stopped container...                          container=ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="xyz-core:1"

但是,当我尝试查看群集中可用或正在运行的图像/容器时,出现以下错误消息:

$ ecs-cli ps --cluster xyz
Name                                            State                                                                                                                                                                                                                                                                            Ports                       TaskDefinition  Health
ea894de8-0c31-4879-90ee-e39909f423a5/mariadb    STOPPED ExitCode: 137                                                                                                                                                                                                                                                            host:8003->3306/tcp  xyz-core:1   UNKNOWN
ea894de8-0c31-4879-90ee-e39909f423a5/webserver  STOPPED Reason: CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/home/manu/project/xyz-core/php                              xyz-core:1   UNKNOWN
ea894de8-0c31-4879-90ee-e39909f423a5/php-fpm    STOPPED ExitCode: 137                                                                                                                                                                                                                                                                                        xyz-core:1   UNKNOWN
efd12ec9-af27-4f2b-abe2-39e9e3a25a68/webserver  STOPPED Reason: CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/home/manu/project/xyz-core/php                              xyz-core:1   UNKNOWN
efd12ec9-af27-4f2b-abe2-39e9e3a25a68/php-fpm    STOPPED                                                                                                                                                                                                                                                                                                      xyz-core:1   UNKNOWN
efd12ec9-af27-4f2b-abe2-39e9e3a25a68/mariadb    STOPPED                                                                                                                                                                                                                                                                                                      xyz-core:1   UNKNOWN

我尝试进行一些搜索,但是找不到解决此问题的任何方法。我是docker-compose和AWS ECS的新手。

请让我知道是否需要其他详细信息来调查此问题。任何帮助将不胜感激。

谢谢

1 个答案:

答案 0 :(得分:1)

如前所述,您应该从docker-compose.yml文件中删除卷。

它应该看起来像这样:

version: "3.0"
services:

    mariadb:
      image: mariadb:10.4
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=food
        - MYSQL_USER=food
        - MYSQL_PASSWORD=123
      ports:
        - "8003:3306"

    webserver:
      build: ./nginx
      image: food-service-webserver:1.0
      ports:
       - "80:80"
       - "443:443"

    php-fpm:
      build: ./php-fpm
      image: food-service-app:1.0

对于网络服务器和php-fpm服务,应该使用单独的Dockerfile来构建映像。

注意:请确保您在ECS群集中启用了强制部署选项。

祝你好运!