Search code examples
amazon-web-servicesamazon-ec2docker-composeamazon-ecs

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?


Solution

  • 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.