pinocchio
pinocchio

Reputation: 131

Running multiple docker instances in EC2

I am new to AWS. So please bear with me if my question doesn't make sense.

My goal is to run multiple docker containers(with different docker config) in one AWS EC2 instance. So far I have been able to programatically start and stop EC2 instance using java SDK.

I guess for running docker instances in EC2 I will have to use ECS Api(AmazonECSClient - included in AWS java SDK). Unfortunately there are hardly any examples that I am able to find for this using AWS java SDK.

Does anybody know how to accomplish this? Any pointers would be helpful.

Upvotes: 2

Views: 1297

Answers (2)

Shibashis
Shibashis

Reputation: 8421

ECS is the container service from amazon and needs you to configure your application to be managed by the service.

If you don't want to use ECS, the only option through ec2 SDK is to define the start of the container through the scripting on user-data section. But you can only control the start of container at the instance bootup.

If you need more control on the docker process start and stop, you may need to add tools for orchestration such as chef, puppet and ansible.

Upvotes: 1

Jerome Anthony
Jerome Anthony

Reputation: 8041

The api documentation here gives a clear enough answer.

You basically;

  1. Create the docker image locally.
  2. Upload/push to your docker registry (e.g., docker hub)
  3. Specify a task definition including your docker image reference.
  4. Launch your cluster based on the container images specified in your task definition.

Upvotes: 2

Related Questions