Installing Flask on Ubuntu

Flask is a micro webdevelopment framework for Python. You are currently looking at the documentation of the development version.

Update

apt-get update 
apt-get upgrade -y

Install python-pip

apt-get install python-pip

Install Flask

pip install Flask

Once the install is complete, let's test it out

vi helloworld.py

Paste the following:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

Exit vi. And run the application,

python helloworld.py

Go to your browser and enter your ip, http://your-ip-address:5000/

If it worked you are all set!

How to Stop and Remove Multiple Docker Containers

One of the things that has always bugged me was going through the process of stopping and removing many containers, is there really just one way to do it? Do I need to do each one, one at a time?

Well after searching I have found the answer.

Stopping All Containers

docker stop $(docker ps -a -q)

Removing All Containers

docker rm $(docker ps -a -q)

This makes it 10x easier for when I want to easily start everything over from scratch

How to Install Docker

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.

Installing Docker is simple for CentOS and even simpler for Ubuntu. Let's look at Ubuntu first, since it is by far the easiest

Ubuntu

Ubuntu 14.04

As always, make sure that your system is up to date.

apt-get update -y

Now install Docker with the simple apt-get install

apt-get install -y docker.io

Update a few of the configurations and you are set.

ln -sf /usr/bin/docker.io /usr/local/bin/docker

sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

Now you can search for Docker images and get started.
http://developer.codero.com/community/searching-for-docker-containers/

CentOS

CentOS 6.5

Add the EPEL to your system

rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Update your machine to make sure that the EPEL is loaded

yum update -y

Run the yum install command to install Docker

yum -y install docker-io

Turn on the chkconfig so docker will be running once you reboot

chkconfig docker on 

Now you can search for Docker images and get started.
http://developer.codero.com/community/searching-for-docker-containers/

Searching for Docker Containers

One of the nice features about Docker is that it is super simple to search for different containers. There is the build in search command:

$ docker search

Usage: docker search TERM

Search the docker index for images

--automated=false    Only show automated builds
--no-trunc=false     Don't truncate output
-s, --stars=0        Only displays with at least xxx stars

So let's say you want to install a Ubuntu container... go over to the search

$ docker search ubuntu

I could paste all the results, but there are way too many. Say you wanted an XMPP server,

$ docker search xmpp

There are a few options,

NAME               
jprjr/metronome  
netmarkjp/hubot-xmpp                                       
rizwankh/xmpp                                               
wunderseltsam/xmpp                                         
rizwankh/xmpp-master                                       
thisgeek/punjab    

Now we can just pull the container down:

$ docker pull jprjr/metronome

If there any dependencies for the container, then they are normally noted.

Install git on Ubuntu

git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Install git on Ubuntu 12.04

$ apt-get install -y git-core

Install git on Ubuntu 14.04

$ apt-get update
$ apt-get install -y git

Configure Git

From the command line run the following commands:

$ git config --global user.name "NewUser"
$ git config --global user.email newuser@example.com

Where NewUser and newuser@example.com are your name and your email address that you wish to use to commit to the project under.

To verify your settings, run:

$ git config --list

Install PHP on CentOS

This guide is a quickest route to installing Apache and PHP on CentOS.

$ yum install -y httpd php 

Now let's start the Apache service

$ service httpd start

Set Apache to run automatically when the server boots:

$ chkconfig httpd on

Verify Installation

Create a new file

$ vi /var/www/html/index.php

Paste the following into the file:

<?php
phpinfo();
?>

:wq to write and exit the file. Now head over to http://your_ip_address. It should look something like this.

** Note: Ensure that your firewall settings are correctly configured. But for a quick test to make sure that everything is working correctly you can temporarily disable iptables:

$ service iptables stop

Once your are satisfied that everything is working, you can re-enable iptables by running:

$ service iptables start