Giter Club home page Giter Club logo

Comments (5)

sayeed-anjum avatar sayeed-anjum commented on August 16, 2024 8

The problem is with stop ecs which fails the first time since the service is not running.

Having the following in your user data script will also work without needing a upstart job.

#!/bin/bash

# Create filesystem on the new EBS device:
mkfs -t ext4 /dev/sdb
mkdir /srv/data/
mount /dev/sdb /srv/data
echo "/dev/sdb       /srv/data   ext4    defaults,nofail        0       2" >> /etc/fstab

# Register as an ECS instance:
yum install -y aws-cli
aws s3 cp s3://<my-bucket>/ecs.config /etc/ecs/ecs.config
echo ECS_CLUSTER=default >> /etc/ecs/ecs.config

# Restart docker service to allow it to see new EBS volume
service docker restart 
start ecs

from amazon-ecs-agent.

euank avatar euank commented on August 16, 2024 4

Hello @ms-ati. I believe this issue is the same as the one in this forum thread.

Per my response there, can you try either restarting the docker daemon after making a mount change (sudo stop ecs && sudo service docker restart && sudo start ecs) or launching docker without the unshare -m command?

Best,
Euan

Edit: To add a little more information, I believe the unshare is there in the first place to work around an issue in docker (see issue and workaround). Please note that if you remove the unshare command rather than restarting docker to propagate mount changes, there might be issues removing stopped containers.

from amazon-ecs-agent.

philipn avatar philipn commented on August 16, 2024 3

If you're curious, here's how I ended up solving the problem. Add this to your user data for the ECS instance:

#upstart-job
description "Pre-ECS agent initialization"
start on (starting ecs or starting docker)
task
script
    # Create filesystem on the new EBS device:
    mkfs -t ext4 /dev/sdb
    mkdir /srv/data/
    mount /dev/sdb /srv/data
    echo "/dev/sdb       /srv/data   ext4    defaults,nofail        0       2" >> /etc/fstab

    # Register as an ECS instance with access to our private docker repositories:
    yum install -y aws-cli
    aws s3 cp s3://<my-bucket>/ecs.config /etc/ecs/ecs.config
    echo ECS_CLUSTER=default >> /etc/ecs/ecs.config
end script

The trick here is to tie the mounting & formatting step to ecs & docker start via an upstart task, ensuring this task runs before ecs or docker are started on the ECS instance.

from amazon-ecs-agent.

ms-ati avatar ms-ati commented on August 16, 2024 1

@euank Thank you kind sir. Restarting the docker daemon after mount change, as you describe above, does indeed fix the issue 👏

from amazon-ecs-agent.

philipn avatar philipn commented on August 16, 2024

@euank Is there any way to do this at ECS instance boot time? When I add the following to my autoscaling configuration user data:

#!/bin/bash

# Create filesystem on the new EBS device:
mkfs -t ext4 /dev/sdb
mkdir /srv/data/
mount /dev/sdb /srv/data
echo "/dev/sdb       /srv/data   ext4    defaults,nofail        0       2" >> /etc/fstab

# Register as an ECS instance:
yum install -y aws-cli
aws s3 cp s3://<my-bucket>/ecs.config /etc/ecs/ecs.config
echo ECS_CLUSTER=default >> /etc/ecs/ecs.config

# Restart docker service to allow it to see new EBS volume
stop ecs && service docker restart && start ecs

I don't see the volume working. SSH'ing into the ECS instance and running stop ecs && service docker restart && start ecs works, but this is much more difficult to automate. I've tried simple variations such as adding stop ecs && service docker stop to the beginning of the user data script and then starting the services at the end, but to no avail.

from amazon-ecs-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.