Recently, I’ve been trying out Let’s Encrypt which is a great new service offering SSL certificates and some automated tools to get them for free! I wanted to see how easy it would be to get going with Let’s Encrypt for a dockerized web application. However, to try that out I realised I’d need a Docker host – with a DNS name that I control – running somewhere. So I’ve written the following guide and some scripts to get that setup. Stay tuned for the next post in which I’ll tell you how to get up and running with Let’s Encrypt.
Docker machine is awesomesauce for getting a docker instance running out on the internet. The included driver amazonec2 allows you to create a docker daemon with one command:
Docker machine is installed along with the docker toolbox.
The docker client works just the same as when it’s connected to your local daemon. To view your running docker daemons, type:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
default - virtualbox Saved
my-lovely-docker-server - amazonec2 Stopped tcp://220.127.116.11:2376
The output of that command shows that default is the name of my local docker daemon, running on virtualbox, and that my-lovely-docker-server is the one running on aws.
To switch your client between docker servers, eval the output from docker-machine env <machine name>
docker-machine env <machine name>
eval "$(docker-machine env my-lovely-docker-server)"
eval "$(docker-machine env default)"
If you want other humans or robots to easily use the services you run on your aws docker machine, you’ll need a static IP and DNS entry.
Before running the script you’ll need to set up three things:-
Set up a new user in AWS. Save the secret key and access key, and attach the AmazonEC2FullAccess and AmazonRoute53FullAccess policies to the new user.
If you dont already have a VPC to use, go to the VPC wizard, and select the option for ‘VPC with a single public subnet’.
Name your VPC and leave the rest of the options as they are.
Register a domain and set up a hosted zone for it on Route53.
You need to have these three pieces of software installed on your machine for the script to work:-
Now, you’ve done the hard part you can run the following to get started.
git clone firstname.lastname@example.org:automationlogic/docker-machine-on-aws.git
export AWS_REGION=your-region-id (I use eu-west-1)
./createDockerInstance.sh www yourdomain.com
You’ll notice in your aws console:-
If you docker run a dockerised web app now, it will be available on www.yourdomain.com.
We work with our clients to de-risk and accelerate their business goals realisation. Our approach is based on tailoring our services to fit your needs leveraging our portfolio of strategy, execution, innovation and service delivery offerings to help you reach your objectives
We’re always on the lookout for exceptional talent and people who share our values. Even as we continue to grow, we maintain a family environment with respect and teamwork core to our culture.
Automation Logic were recognised as one of the UK’s best Workplaces again for the 5th year running! We also placed 29th in best workplaces for women. This highlights the great work that we are doing as a business, including all the wonderful work being put in by the employee-led DE&I groups. This award means so […]
Once a year we get together for ‘AL fest’ to thank all of our employees for the amazing work they do and allow them a weekend of bonding. There’s something for everyone, from our internal talent show allowing people to showcase their talents, from musical, comedy, and anything else they excel at outside of the […]
Ynyr has been with Automation Logic for several years now and his client feedback is consistently glowing. Ynyr is somewhat of a security superhero in his field, helping clients with high-impact work, and trusted implicity to do so. We can’t think of anyone more deserving of the Young Digital Professional award. Congratulations Ynyr, and thank […]