Deploying Meteor With Docker on AWS ECS

I originally gave a talk on this subject for April’s Meteor Dev Shop NYC. The slides are available here:

Installing Docker

If you already have Docker installed move along. Otherwise: has install instructions for Mac and links for Linux and Windows. I haven’t found installing docker to be 100% painless, namely that after installing they give you a “Docker Quickstart Terminal”, but if you’re like me and like running your own terminal like iTerm you’ll need to often use this handy command: `eval $(docker-machine env default — shell bash)`

Our MongoDB

While that previous step is building, we can spend this time looking for a database. Assuming your app uses MongoDB, we’re going to want to have a separate database instance that our app can connect to. I use for lots of things because it’s good and free. But is another great solution if you’re looking for something that has Oplog support right out the box. In any case you’re going to need a database.

As you can see in that error message you’ll need to click there to create a user//pass with admin privleges to give your meteor app.

Once you’ve got your mongodb:// URL with a username/pass we’re ready to move on.

Meteor App

Assuming you have your meteor app finished and you’re ready to push it out the world here’s how you can do it in a nice scalable way.

Use (The docs here are great so feel free to just go off that README if you run into any issues on these steps.)

  1. Put a Dockerfile (plain text file with the name “Dockerfile”) in the root of your app with just the text “FROM meteorhacks/meteord:onbuild”.
  2. Then run `docker build -t yourname/app .` (don’t ignore the “ .” at the end). This step might take a while as you’re building the entire image of a container that is capable of running meteor (with your app).
  3. Once that’s all done you can test it your app by running:
docker run -d \
 -e ROOT_URL= \
 -e MONGO_URL=mongodb://url \
 -e MONGO_OPLOG_URL=mongodb://oplog_url \
 -p 8080:80 \

If you’re new to Docker, after running this (assuming it didn’t throw an error) you should be able to find your Docker containers IP address by running`docker-machine ls` you can then go to your docker machine’s ip address:8080 to view your webpage.

In this case I ran -p 80:80 in docker run so that I can just go to instead of

If everything is working good and well on there then you’re good to move on the the next step!… setting up AWS.

NOTE: If you get some error like that first one, try running that `eval…` command listed above.


You’re going to want to click on EC2 Container Service.

The documentation and UI menus on AWS always seem a bit confusing.

If for some reason clicking on that EC2 Container Service link doesn’t give you the wizard with instructions try going to this url:

Basically the main things you want to do are:

1) Create a docker repository on amazons’ ECS section. (this could but does not have to match your same yourname/app).

2) Once you do that it will give you instructions on how to build, tag, and push your docker image.

You’ll want to run these commands: with that second docker login command being the output of the first command.

$> aws ecr get-login — region us-east-1
$> docker login -u AWS -p ……
$> eval $(docker-machine env default — shell bash)
$> docker tag justink/test13:latest …
$> docker push 06…

Now that you’ve pushed your repository onto AWS, you’ll want to set up your actual servers and instances that will run your meteor app.

Do this by creating a task definition and putting the amazon image in the Image section.

You’ll want to make sure that your port mappings are mapping 80 to 80.

Also you’ll need to go into advanced options and set up env variables including your ROOT_URL, MONGO_URL, and any other things that you ran in the docker run step (possible METEOR_SETTINGS param).

Here’s a video followed by some screenshots of me setting this up:

Video of the process of setting up AWS ECS
Once everything finishes this button should turn blue and you can see the services running :)
You’ll want to click here to do the final settings (this is your cluster’s load balancer)
Sticky sessions are pretty crucial for most Meteor apps. Read more:
This is what you need to check to make sure you’ve got sticky sessions enabled.
Possible success? from 1 instance to 2 avg time went from ~1400ms to ~750ms

I know this probably isn’t the most clear set of instructions but I really hope it’s enough to help someone get a working set up! I’ll try to edit this to make instructions more clear and would love any feedback from anyone trying this out themselves as to how I could make clearer directions. I’m also happy to try to help anyone with questions via email to

Up next will be an article on how to scale up and update your application once you get this single instance set up!