One . Before reuse, a package SSH Mirror image , If there is no encapsulation SSH, You can use your own image or refer to my previous blog : Challenge OpenStack: use Docker Realize private cloud   The first five steps

And then there's the subject .

Two . Deployment process

1. Look at the mirror image

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu sshd f61f7079461c hours ago 666.3 MB

2. stay /home It's set up docker Catalog , Download a django-1.7 The source package ,touch dockerfile and run.sh, among run.sh It's used to carry out Django Of bash Script ,Dockerfile It's automatic build python

The file of , The core of this article is also Dockerfile.

root@iZ2893wjzgyZ:/home/docker# ls
Django-1.7..tar.gz Dockerfile run.sh

3. To write Dockerfile

FROM ubuntu:sshd
MAINTAINER Alex RUN apt-get update
RUN apt-get install -y -q python-pip
RUN pip install setuptools
ADD Django-1.7..tar.gz /opt/ WORKDIR /opt/
RUN mv Django-1.7. django WORKDIR /opt/django
RUN python setup.py install WORKDIR /opt
RUN django-admin.py startproject mysite ADD run.sh /opt/mysite/run.sh
WORKDIR /opt/mysite
RUN chmod run.sh
EXPOSE
CMD ["/bin/sh","run.sh"]

4. To write run.sh

python manage.py runserver 0.0.0.0:

3、 ... and . Begin to build

root@iZ2893wjzgyZ:/home/docker# sudo docker build -t ubuntu:web .

After building , You can see that a new image is generated :

And one exposed 8080 New container for ports :

Four . At this point, the background starts the image , And put 8080 Port mapping out :

root@iZ2893wjzgyZ:/home/docker# docker run -d -p : ubuntu:web

netstat Check the host's 8080 port

5、 ... and . Use and commissioning

Complete the above four steps , This package is ready to use django Mirror image , Next, take a look at the login screen

If you need to check log journal , You can use the following command ,-f On behalf of continuous printing :

#docker logs -f container_id 

If you need to go into the container to modify web Content , Can pass ssh Connect into , A similar explanation has been given before , I won't go into details here .

6、 ... and . Export the mirror

root@iZ2893wjzgyZ:/home/docker# docker save -o ubuntu14.04_djangodemo.tar.gz ubuntu:web

use Docker Encapsulates a web application (Django) More articles about

  1. Docker Run one Web application

    Use docker Construct a web Applications . We will be in docker Run a... In the container Python Flask Application to run a web application Parameter description : -d: Let the container run in the background . -P: The net used inside the container ...

  2. How to use Docker Deploy one based on Play Framework Of Scala Web application ?

    The author of this article Jacek Laskowski Close to 20 Years of application development experience , present CodiLime Our software development team Leader, Zeng IBM Get a variety of qualifications . In this post ,Jacek Shared Wars ...

  3. How to use Docker Deploy a Go Web Applications

    be familiar with Docker How to improve what you're building . Test and deploy Go Web How the application works , And understand how to use Semaphore To continuously deploy . brief introduction Most of the time Go The application is compiled into a single binary ,web The application includes templates ...

  4. requests+django+bs4 Achieve one web Functions of wechat

    Preface : Today we use requests modular +django+bs4 Browser to implement a web The basic functions of wechat , The main functions are as follows a. The implementation returns the QR code b. After scanning the mobile phone code, the QR code becomes the head image c. The realization of mobile phone click login into ...

  5. Anaconda+django Write the first web app( Ten )

    Today we continue to learn how to use foreign keys . When we have category.series And a lot of tutorials when , Let's look at some tutorial, You might need a path like this http://127.0.0.1:8000/categor ...

  6. Anaconda+django Write the first web app( One )

    After installation Anaconda and django after , We can start to create our first Web app, So first create an empty folder , All the files created after that are in this folder . Start the command line to enter this folder , You can first view a ...

  7. 【 Cloud computing 】Docker Centralization web Interface management platform shipyard

    Docker Centralization web Interface management platform shipyard docker shipyard seanlook                        2015 year 01 month 05 Promulgated by the              ...

  8. Use Docker build Java Web Running environment

    Huang Yong's blog Docker yes 2014 One of the hottest technologies of the year , Almost all programmers have heard of it .Docker It's a kind of “ Lightweight ” Container technology , It almost shakes the position of traditional virtualization technology , Now more and more companies at home and abroad have begun to pursue ...

  9. turn : Use Docker build Java Web Running environment

    Original from :http://www.codeceo.com/article/docker-java-web-runtime.html Docker yes 2014 One of the hottest technologies of the year , Almost all programmers ...

Random recommendation

  1. Servlet filter ,Servlet Filter creation and configuration

    First of all :Servlet The creation and configuration of the filter , To create a filter object, you need to implement javax.servlet.Filter Interface , At the same time to realize Filter Of 3 A way .        The first method is in the filter init() Method use ...

  2. cocos2d Learning notes 1

    CCDirector Main role of : 1. Access and change the scene : 2. visit cocos2d-x Configuration details of 3. Access view (OPENGL,UIVIEW,UIWINDOW): 4. Pause , Restore and end the game : 5. stay UIKi ...

  3. Ali maven Warehouse address and oschina maven Warehouse address

    <mirror>     <id>nexus-aliyun</id>     <mirrorOf>*</mirrorOf>     < ...

  4. C# WebAPI series (1)

    WebApi It's Microsoft. VS2012 MVC4 Version of ,WebApi Is completely based on Restful Standard framework .RestFul: ( english :Representational State Transfer, Jane ...

  5. beego Various forms of routing instances

    Basic routing The basic route is and http.Handle and http.HandleFunc The same is bound to a fixed path , Like binding 4 A routing map : Defined 4 In a controller , Which route to match , Output the corresponding control name . beego.R ...

  6. rpm Command to use and lsof -p 1406 Use

    # install RPM -v  Show details -h  Show progress -i  install -U  upgrade -q  Inquire about -ql  see rpm  Packaging documents - qf  See which command belongs to RPM  package -qi  see RPM Package details [root@ ...

  7. C# flow (stream)

    http://www.cnblogs.com/liuxinls/archive/2013/02/15/2912968.html Stream is used to IO Handle stay System.IO There are the following classes in the namespace BinaryR ...

  8. Python pack -py2exe

    The last article said pyinstaller, It can be packaged to include Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX And other executable files under the operating system , If only for Windows ...

  9. About vue.js in slot The understanding of the

    slot Look at the official website , I didn't understand at first , After careful study, I finally understood ,slot What is it for , Let's look at the next example : <script src="https://unpkg.com/vue/dist/ ...

  10. Network in Network(NiN)

    - Mlpconv layer with "micronetwork" with each conv layer to compute more abstract features ...