Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Failed to initialize logging driver occurred when specify logging driver awslogs #752

Closed
kodomo898 opened this issue Mar 19, 2019 · 5 comments
Assignees

Comments

@kodomo898
Copy link

Summary

When ecs-clis specified ecs-params.yml / docker-compose.yml and executed, the following error occurred.

CannotStartContainerError: Error response from daemon: failed to initialize logging driver: CredentialsEndpointError: failed to load credentials caused by: RequestError: send request failed caused by: Get http://169.254.170.2/v2/credentials/ //container-id//

http://169.254.170.2/v2/ can only be used in awsvpc mode

but

I want to set the container’s PORT as random.

Description

I implemented the following command

platform: MacOS

ecs-cli compose --debug service --cluster app-staging up

Config files

  • docker-compose.yml
version: '2'
services:
  app:
    image: <image>
    command: bundle exec puma -e production -C config/puma.rb
    env_file:
      - .env.app.staging
    working_dir: /projects/app

    logging:
      driver: "awslogs"
      options:
        awslogs-region: "ap-northeast-1"
        awslogs-group: "app-staging/test-app"
        awslogs-stream-prefix: "app"

  nginx:
    image: <image>
    entrypoint:
      - /bin/bash
      - /etc/nginx/start.sh
    ports:
      - 0:80
    links:
      - "app:app"
    env_file:
      - .env.nginx.staging
    working_dir: /projects/nginx

    logging:
      driver: "awslogs"
      options:
        awslogs-region: "ap-northeast-1"
        awslogs-group: "nginx-staging/nginx"
        awslogs-stream-prefix: "nginx"

  • ecs-params.yml
version: 1
task_definition:
  ecs_network_mode: bridge
  task_role: ecsServiceTaskRole
  task_execution_role: ecsServiceTaskRole
  services:
    coda-app:
      essential: true
      secrets:
         - value_from: /app-staging/SECRET_KEY_BASE
           name: SECRET_KEY_BASE

    coda-nginx:
      essential: true
  run_params:
    network_configuration:
      awsvpc_configuration:
        subnets:
          - <subnet>
        security_groups:
          - <sg>
  • ~/.ecs/config
version: v1
default: app-staging
clusters:
  app-staging:
    cluster: app-staging
    region: ap-northeast-1
    default_launch_type: ""
@kodomo898 kodomo898 changed the title I get an error when I put the logging driver failed to initialize logging driver occured in logging driver awslogs Mar 19, 2019
@kodomo898 kodomo898 changed the title failed to initialize logging driver occured in logging driver awslogs Error Failed to initialize logging driver occurred when specify logging driver awslogs Mar 19, 2019
@kodomo898 kodomo898 changed the title Error Failed to initialize logging driver occurred when specify logging driver awslogs Error Failed to initialize logging driver occurred when specify logging driver awslogs Mar 19, 2019
@kodomo898 kodomo898 changed the title Error Failed to initialize logging driver occurred when specify logging driver awslogs Error Failed to initialize logging driver occurred when specify logging driver awslogs Mar 19, 2019
@kodomo898
Copy link
Author

Need to be AmazonLinux2?

@PettitWesley
Copy link
Contributor

@kodomo898 Sorry for the delay in response. What version of the Agent are you running?

I found an agent issue which seems similar: aws/amazon-ecs-agent#1230

@petderek
Copy link
Contributor

petderek commented Apr 2, 2019

@kodomo898 Are you using a custom AMI? You don't need to use Amazon Linux 2, but you do need to do some setup in order to get the credential handler working. Specifically:

# Set up necessary rules to enable IAM roles for tasks
sysctl -w net.ipv4.conf.all.route_localnet=1
iptables -t nat -A PREROUTING -p tcp -d 169.254.170.2 --dport 80 -j DNAT --to-destination 127.0.0.1:51679
iptables -t nat -A OUTPUT -d 169.254.170.2 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 51679

See:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html
https://github.com/aws/amazon-ecs-agent#on-other-linux-amis

@kodomo898
Copy link
Author

kodomo898 commented Apr 5, 2019

@PettitWesley
thanks!!
i use amazon ecs agent version 1.26.0.
i will read aws/amazon-ecs-agent#1230 and try again.

@kodomo898
Copy link
Author

@petderek
these commnds worked fine!!
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants