簡體   English   中英

AWS ECS上的Docker容器始終顯示已停止

[英]Docker containers on AWS ECS always shows STOPPED

我正在使用CodePiepline設置新的AWS ECS集群。 我正在關注以下文檔: AWS ECS博客

這是我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的新手。

如果需要其他任何詳細信息來調查此問題,請告訴我。 任何幫助將不勝感激。

謝謝

如前所述,您應該從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

對於Web服務器和php-fpm服務,應該有單獨的Dockerfile來構建映像。

注意:請確保在ECS群集中啟用強制部署選項。

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM