AWS ECS repository creation with EC2 - amazon-web-services

Hello,
I have a running EC2 with applications installed and I want to migrate the app onto Docker container.So, can we create an ECS Docker repository using running EC2 instance?

The biggest thing in your question is dockerizing your apps.The complexity varies as per technologies used in app, app server as docker image and many other things comes into picture.Its not direct conversion and you need to do lot of work to convert apps as docker images depends app comlexity.
ECR is docker registry where you store docker images and you don't need ec2 instance for that.
Once you docker images and ECR, you need to create ECS cluster to run your apps docker containers.

Related

Deploying specific docker services locally when running docker-compose with ECS

I have a docker-compose.yml file that deploys several services to AWS ECS. This works fine. However, there are some services that I don't want deployed to ECS. I would like for these docker containers to run locally instead WHILE the other services are deployed on AWS ECS.
I can't find any documentation on this. What settings would I have to set in my docker-compose.yml file so that a specific service is built and run locally instead of being deployed to AWS ECS?
It sounds like you need to create two separate docker-compose.yaml files. One could be called local-only-compose.yaml or something. When running locally you can pass multiple compose YAML files to docker-compose. When deploying to AWS you could pass only the file with the services you want to deploy to ECS.

Can you network between ECS Fargate tasks using the container name as hostname?

I was handed a docker image which previously was being deployed using docker compose and because of that it could connect to the database using db-containername as the database's hostname. Now that I'm trying to deploy these containers as ECS Fargate tasks however I'm getting UnknownHostException: db-containername.
Is there a way that this can be fixed from the outside without changing the underlying image? And if I do have to rebuild the image how should this be done ideally?

How properly deploy Docker Compose to Amason EC2 instance?

I'm having docker-compose config with postgres, 2*python, nginx and redis services. Now I'm instantiated an ec2 instance and successfully logged in via .pem file. But I expected, that I can deploy my docker-compose image only with aws-cli commands. My question is should I instantiate ec2 for each of service and how to use ec2 with docker-compose properly?
How you want to design your infrastructure - how many servers, autoscaling, routing, etc - is entirely up to you.
To answer your question though; to deploy a docker-compose.yml file you do so the same as you would on any other server.
docker-compose is a tool made for development and is not made to be used in Production - you should deploy your services with:
docker stack deploy -c your-compose-file.yml your_stack_name
It sounds like this is new to you though; so I should state that there are various options that are available with docker-compose that are not available with docker stack deploy. Often times you can't just use the same compose file as you're using in development.

Recommendation: Deploy Docker application to AWS

I got a local Docker stack running Node.js, MongoDB and Nginx.
It runs perfectly using docker-compose up --build.
Now it's time to deploy my application to a production environment.
I have considered EC2 Container Service and EC2, but can you recommend an easier approach? The learning curve is steep!
For MongoDB -
Use AWS quick start MongoDB
http://docs.aws.amazon.com/quickstart/latest/mongodb/overview.html
http://docs.aws.amazon.com/quickstart/latest/mongodb/architecture.html
For rest of the docker stack i.e NodeJS & Nginx -
Use the AWS ElasticBeanstalk Multi Container Deployment
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html
Elastic Beanstalk supports Docker, as documented here. Elastic Beanstalk would manage the EC2 resources for you so that you, which should make things a bit easier on you.
You can install Kontena to AWS and use that to deploy your application to production environment (of course other cloud providers are also supported). Transition from Docker Compose is very smooth since kontena.yml uses similar syntax and keys as docker-compose.yml.
With Kontena you will have private image registry, load balancer and secret management built-in that are very useful when running containers in production.

running a docker loop device on aws

I'm new to aws and am having some issues with getting my mobile app back running again. Forgive me if this question seems vague.
For a school project we created a mobile app on aws and deployed using docker containers (another student managed these tasks). When trying to get my own key pair to ssh into my ec2 instance i detached the volume associated with my instance and reattached it after getting my own key pair. Now i can ssh into my instance but my front end cant talk to my web server.
So my question is, do i create a new application on elastic beanstalk to deploy my app? Even though when i run lsblk is shows a have a docker loop device and when i run docker images i see several that match the name of my application? or do i somehow get the container running again, docker run doesn't seem to be working.
No need, just upload a new update into Elastic Beanstalk. AWS will handle the rest.
FYI, Elastic Beanstalk - Single Docker Container update process (simple under the hood):
You upload the update into AWS.
AWS will put it on your S3.
Inside your EC2, there is an Elastic Beanstalk agent. It will check for a new update.
If there is an update, the agent will download the update file and extract it.
The agent will build a new Docker image.
If the build is success, it will generate a new config to tell Nginx (web proxy) the new web server container.
Nginx will be reloaded.
Your old docker container will be destroyed.
Don't change anything inside EC2 of Elastic Beanstalk, except you know what you do. Elastic Beanstalk is design for automate deployment and scaling. So, if you change something in your EC2 manually, it might be lost. Of course, you can modified your EC2 instance, but you need to automate it using .ebextensions or take an image.