AWS OpsWorks Docker can be easily accomplished with a little help from our experts.
At Bobcares, we offer solutions for every query, big and small, as a part of our AWS Support Services.
Let’s take a look at how our AWS Support Team is ready to help customers with AWS OpsWorks Docker.
What is AWS OpsWorks Docker
AWS OpsWorks allows us to deploy as well as manage different applications. Furthermore, we can create instances for EC2 instances for installing and configuring any software we want. We can use templates or build our own via Chef recipes.
These templates allow us to install software packages and carry out any task we script. Furthermore, AWS OpsWorks has the ability to scale our application via application load-based or time-based scaling. It also maintains the health of the application by keeping an eye out for failed instances and replacing them in time.
Here are some of the reasons why Docker on AWS OpsWorks is a good choice.
- Automation of AWS resources
- Full control of Docker version and installation
- Resource discovery
- Full control of mapping containers to instances
How to run Docker on AWS OpsWorks
The AWS OpsWorks Docker process involves the following steps:
- Create recipes
- Create an OpsWorks Stack
- Add a layer
- Add an instance
- Add an app & deploy
- Make attributes dynamic
How to create recipes on AWS OpsWorks
To begin with, create a repository to store the Chef recipes. The following docker::install recipe installs the requisite Docker software on AWS OpsWorks:
case node[:platform] when "ubuntu","debian" package "docker.io" do action :install end when 'centos','redhat','fedora','amazon' package "docker" do action :install end end service "docker" do action :start end
Moreover, the following docker::docker-deploy recipe deploys the docker containers on AWS OpsWorks:
include_recipe 'deploy' node[:deploy].each do |application, deploy| if node[:opsworks][:instance][:layers].first != deploy[:environment_variables][:layer] Chef::Log.debug("Skipping deploy::docker application #{application} as it is not deployed to this layer") next end opsworks_deploy_dir do user deploy[:user] group deploy[:group] path deploy[:deploy_to] end opsworks_deploy do deploy_data deploy app application end bash "docker-cleanup" do user "root" code <<-EOH if docker ps | grep #{deploy[:application]}; then docker stop #{deploy[:application]} sleep 3 docker rm #{deploy[:application]} sleep 3 fi if docker images | grep #{deploy[:application]}; then docker rmi #{deploy[:application]} fi EOH end bash "docker-build" do user "root" cwd "#{deploy[:deploy_to]}/current" code <<-EOH docker build -t=#{deploy[:application]} . > #{deploy[:application]}-docker.out EOH end dockerenvs = " " deploy[:environment_variables].each do |key, value| dockerenvs=dockerenvs+" -e "+key+"="+value end bash "docker-run" do user "root" cwd "#{deploy[:deploy_to]}/current" code <<-EOH docker run #{dockerenvs} -p #{node[:opsworks][:instance][:private_ip]}:#{deploy[:environment_variables][:service_port]}:#{deploy[:environment_variables][:container_port]} --name #{deploy[:application]} -d #{deploy[:application]} EOH end end
After that, we have to create a repository to store the Dockerfile.
How to create an OpsWorks Stack
- First, open the AWS OpsWorks console.
- Then, select Add a Stack and choose Advanced.
- Next, set Use custom Chef Cookbooks to Yes and Repository type to Git.
- After that set the Repository URL to the repository where we store recipes from the previous step.
How to add a layer
- In the AWS OpsWorks console, select Add Layer.
- Then select Custom Layer and set name to “Docker” and shortname to “docker” and then clickAdd Layer.
- Next, select the layer’s Edit Recipes action and head to the Custom Chef recipes section.
- After that, enter docker::install in the Setup box and docker::docker-deploy in the Deploy box and click +.
- Finally, click the Save button.
How to add an instance
By this point, the Layer page will display the Docker layer on AWS OpsWorks. Now, we have to add instances to the layer by selecting Instances from the Docker layer and selecting +. Accept the default settings and select Add Instance. We have to select Start from the actions column in the row in order to start the instance. This launches a new EC2 instance and also runs the Setup recipes in order to configure Docker.
After starting the instance we have to add an app and deploy it. This is done via the AWS OpsWorks console. After deploying the app, we will be able to see the app by clicking the server’s public IP address. Then, we have to update AWS OpsWorks attributes to complete the process.
If you run into trouble with setting up AWS OpsWorks Docker, our AWS experts are here to help you out.
[Need assistance with another query? We are available 24/7.]
Conclusion
In a nutshell, our skilled AWS Support Engineers at Bobcares introduced AWS OpsWorks Docker to us.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments