Building a Django environment using the IBM Bluemix container

Source: Internet
Author: User
Tags ssh install django pip install django
Building a Django environment using the IBM Bluemix container Create a user

First you need to create a user on the IBM bluemix
To create a successful user, you can access the IBM Bluemix Dashboard
https://console.ng.bluemix.net/ Install cloudfoundry command line tool

You can download the installation package from the link below
Https://github.com/cloudfoundry/cli#downloads
Https://cli.run.pivotal.io/stable?release=redhat64&source=github

For CentOS, use the second link, and then install the RPM package

sudo yum install cf-cli-installer_6.14.0_x86-64.rpm
Install Docker Install IC Plugin
CF Install-plugin Https://static-ice.ng.bluemix.net/ibm-containers-linux_x64

After installation, you can use CF plugins to view settings namespace

To use the IBM bluemix container, you must first create a namespace to act as the user's container warehouse

CF IC namespace set [My_namespace]
CF IC namespace get

You can also create on the dashboard page, select container on the dashboard, and then select a container image on the right pops up a window for input namespace to log on with the CF command line

CF Login-a Https://api.ng.bluemix.net
Initialization of
CF IC Init

After initialization, you can use the CF command to view some information, such as:
View mirror List

CF IC images
REPOSITORY                                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
registry.ng.bluemix.net/ Ibm-mobilefirst-starter   Latest              5996bb6e51a1        6 weeks ago         770.4 MB
registry.ng.bluemix.net/ IBM-NODE-STRONG-PM        Latest              ef21e9d1656c        8 weeks ago         528.7 MB
registry.ng.bluemix.net/ Ibmliberty                Latest              2209a9732f35        8 weeks ago         492.8 MB
Registry.ng.bluemix.net/ibmnode                   Latest              8f962f6afc9a        8 weeks ago         429 MB

View the IP list, where Bluemix will default to two public IP, because the container has not yet been created. All this list may be empty, and after you create the container, you will see a container bound to the public IP

CF IC IP List
Create a container mirror dockerfile

Build a directory, such as MyTest, and then create a dockerfile under it, which reads

=========================================================== from
centos:centos7

maintainer Fanbin Kong " Kongxx@hotmail.com "

RUN rpm-ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
RUN yum install-y openssh-server sudo python-pip

Run pip install Django 
run pip install djangorestframework

run sed-i ' s/usepam yes/usepam ' no/g Fig

Run echo "Root:letmein" | chpasswd

run ssh-keygen-t dsa-f/etc/ssh/ssh_host_dsa_key
run ssh-keygen-t R Sa-f/etc/ssh/ssh_host_rsa_key
RUN mkdir/var/run/sshd

expose
CMD ["/usr/sbin/sshd", "D"]
To create a container mirror
CF IC Build-t mytest:v1.

When you are done with the "CF IC images" view, you will see the newly created MYTEST:V1 mirror

CF IC images
REPOSITORY                                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
registry.ng.bluemix.net/kongxx/ MyTest             v1                  63f1d401ab8c        9 minutes ago       340.8 MB
registry.ng.bluemix.net/kongxx/mytest             Latest              63f1d401ab8c        minutes ago      340.8 MB
registry.ng.bluemix.net/ibm-mobilefirst-starter   Latest              5996bb6e51a1        6 weeks ago         770.4 MB
registry.ng.bluemix.net/ibm-node-strong-pm        Latest              ef21e9d1656c        8 weeks ago         528.7 MB
registry.ng.bluemix.net/ibmliberty                Latest              2209a9732f35        8 weeks ago         492.8 MB
registry.ng.bluemix.net/ibmnode                   latest              8f962f6afc9a        8 weeks ago         429 MB
Start Container
CF IC Run--name=test-d-P REGISTRY.NG.BLUEMIX.NET/[NAMESPACE]/MYTEST:V1

After starting, wait a moment, then run "CF IC Inspect Test | grep IP to view the IP address. If you see it is empty, then wait and then run.
If you see IP, you can use CF IC IP list to view the binding relationship between IP and container, if no binding succeeds, you can use the following command to bind

CF IC IP {list,bind,unbind,request,release} [ip_address] [container_instance_id]

The launch of the container can also be done on the Bluemix dashboard, and the container can also be bound to the IP address, because the graphics operation is not said here. Access Container

After starting the container in the previous step and using the CF IC Inspect Test | grep IP "After obtaining the IP address, we can login ssh." The above container is created using Root/letmein as the username and password. Test Django

Run the following command to create and start the Django application

django-admin.py startproject myapp
cd MyApp python manage.py runserver 0.0.0.0:8000

When you visit http://[ip]:8000/in your browser, you can see the Django initial page.

Reprint please indicate this address in the form of link
This article address: http://blog.csdn.net/kongxx/article/details/50219577

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.