Jashwant
Jashwant

Reputation: 29005

Docker for production EC2

I am new to Docker.

From what I understand, it creates portable environment to run and ship apps to multiple platforms with same set of software configuration. This way, it also does not conflict with softwares in your machine.

I've used Docker in development and understand that it's very good for development and to share code with other team members. Each gets a non-conflicting same set of softwares to run.

Now,

I am thinking to use docker on production. Install docker on EC2 and everything will be installed/configured in 1 command.

But I have few questions:

  1. Why would I install something in EC2 inside container. I am going to install just 1 app and there's no chance of conflict. Wont' it be slow as it is inside container and any issue in docker will break my app ? What will happen to my data if I destroy it somehow ?
  2. Can I use Docker somehow that app does not live inside container, but in OS directly ?
  3. What alternative can I use to do deploy my small flask app in just 1 click ( database, nginx, flask, haproxy etc ?. It is just a small app and I do not want to complex things and waste money. Open source solutions are welcomed.
  4. Internet is full of articles which seem to be industry standard and are for big apps/websites. Too many tools/technologies to learn. Chef, puppet, jenkins, kubernetes. Will I be able to live without these for small websites or will it be the way forward and I'll have to learn these eventually ?

Upvotes: 2

Views: 1139

Answers (2)

Edward Aung
Edward Aung

Reputation: 3512

I have been using docker for productionizing AI solutions for clients in financial sectors.

Why would I install something in EC2 inside container. I am going to install just 1 app and there's no chance of conflict. Wont' it be slow as it is inside container and any issue in docker will break my app ? What will happen to my data if I destroy it somehow ?

Although you can manage docker in your EC2, the standard (and better) practice is to use kubernetes or docker swarm to manage it on a couple of EC2 nodes automatically. AWS has some service for that.

Since docker runs your process directly on the host's kernel, there will be no visible performance hit. For I/O, you should use purpose-built docker volumes (this relates to next point).

If you destroy a container, all data within it will be gone. To prevent it, you can use docker volumes. Since you know where your app is going to write data in, you know where to mount them.

Can I use Docker somehow that app does not live inside container, but in OS directly ? What alternative can I use to do deploy my small flask app in just 1 click ( database, nginx, flask, haproxy etc ?. It is just a small app and I do not want to complex things and waste money. Open source solutions are welcomed.

See above. Process runs directly in host's kernel. Data should go to docker volumes. Use docker-compose (that is a short hand to deploy multiple containers in a specified configuration in one go). docker-compose is open-source.

Internet is full of articles which seem to be industry standard and are for big apps/websites. Too many tools/technologies to learn. Chef, puppet, jenkins, kubernetes. Will I be able to live without these for small websites or will it be the way forward and I'll have to learn these eventually ?

Yes, but they exist for a reason. They abstract away some of your pain points. If your small webapp is manageable (and has less pain), you can manage docker on EC2 yourself (or even put bare metal app on top of EC2 like in 2000s). However, as your app grows in complexity, you may observe more pain points and depending on your pain point, use specific tool. Chef, PUppet, Jenkins, Kubernetes (and Openshift) have multiple areas overlapped. You don't need all. Depending on your pain point, you can use just one or two (using all, in my opinion is a bit crazy).

Upvotes: 3

cecunami
cecunami

Reputation: 1037

Why would I install something in EC2 inside container. I am going to install just 1 app and there's no chance of conflict.

Yes, you are right. If you install a single app, there is no chance of conflict. However, sometimes, you want to run multiple applications on the same host. This is usually done to fully utilize the resources of the server. Also, some apps need to be deployed on the same machine in order to function correctly.

Wont' it be slow as it is inside container

Here is an excellent 2014 IBM research paper titled "An Updated Performance Comparison of Virtual Machines and Linux Containers" by Felter et al. that provides a comparison between bare metal, KVM, and Docker containers. The general result is that Docker is nearly identical to Native performance and faster than KVM in every category.

and any issue in docker will break my app?

An issue in the EC2 machine will also break your app. Your app should be resilient to failure. This is one benefit on deploying your apps in Kubernetes (it will automatically restart your containers on failure).

What will happen to my data if I destroy it somehow?

You can mount volumes on the container which will persist after the container is deleted. Those volumes can be stored on the EC2 machine file system or on some external storage. (Keep in mind that everything can go down. You should always back-up your data.)

Can I use Docker somehow that app does not live inside container, but in OS directly ?

You don't need Docker for that.

What alternative can I use to do deploy my small flask app in just 1 click ( database, nginx, flask, haproxy etc ?. It is just a small app and I do not want to complex things and waste money. Open source solutions are welcomed.

Look into Docker Compose. It allows you to deploy apps that are comprised of multiple containers with a single command. It is open-source and free to use. (You can also get away with Ansible, Chef, Puppet) You really need just one of those.

Internet is full of articles which seem to be industry standard and are for big apps/websites. Too many tools/technologies to learn. Chef, puppet, jenkins, kubernetes. Will I be able to live without these for small websites or will it be the way forward and I'll have to learn these eventually?

People were able to develop and deploy websites long before the invention of those tools, so you definitely can do it! However, without those tools, it becomes much harder to develop and operate and application that has to be reliable, highly available and scalable.

The one that is a must for an application is a good CI/CD pipeline that automatically builds, tests and deploys your application. Doing this stuff manually can quickly get out of hand if the above process is complex enough. Having a good CI/CD pipeline allows the developers to focus on coding new features instead of constantly managing the operations part of the process. It allows them to deliver code continuously and reliably. Jenkins, Chef, puppet, Ansible, Docker compose, Gitlab CI and others try to solve those exact problems. However, for most apps, Jenkins is usually enough to achieve this.

Upvotes: 10

Related Questions