Code Monkey home page Code Monkey logo

docker_container_on_aws_ec2's Introduction

Docker Container on AWS EC2

containerized my personal website and run it on AWS EC2 instance

Description

In this lab, I launch EC2 instance on configured infrastructure (see Lab 2), install Docker on EC2, create a custom Docker container - copy over an existing application, install and launch web server, build and tag the Docker image, run application from Docker container on EC2 instance, push Docker container to Docker Hub.

Usage

To create custom EC2 instance on configured infrastructure, run:

python kbosko-lab3.py

While creating EC2 instance, the shell script Docker.sh is executed which installs Docker and Apache web server, creates Docker container, builds it and runs it.

Docker container runs my website www.cross-validated.com which is downloaded from S3 bucket created in previous Lab 2.

NOTE: you need to paste your own resources both in python and bash scripts.

Debugging

There are several ways to debug if got stuck:

  1. Attach shell to docker container
#check docker ID
docker ps
docker exec -it {container ID} bash
  1. Check log file for EC2 instance through AWS management console

Right-click on EC2 instance --> Monitor and troubleshoot --> Get system log

  1. Check log file for container after SSH into the instance from local machine
sudo less  /var/log/cloud-init-output.log

See documentation on how to Run commands on your Linux instance at launch

  1. Check that UserData got attached to EC2 instance from AWS management console

Right-click on instance --> Instance Settings --> View/Change User Data

Pushing Docker Container to Docker Hub

Pushing Docker container to repo in Docker Hub:

  1. Create repository in Docker Hub
  2. Docker login
  3. Retag your Docker container

docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]

or when building assign correct tags

docker build -t <hub-user>/<repo-name>[:<tag>]

  1. Docker push

docker push <hub-user>/<repo-name>:<tag>

See documentation here

docker_container_on_aws_ec2's People

Contributors

k-bosko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.