zoukankan      html  css  js  c++  java
  • Docker部署之用dockerfile创建Django镜像

    1. vim dockerfile-django

    2. 进入文本编辑:

    参考 :http://www.open-open.com/lib/view/open1423703640748.html

      dockfile中,常用 FROM , MAINTAINER , RUN  , CMD ,  EXPOSE , ENV ,  ADD ,  COPY ,  ENTRYPOINT ,  VOLUMNE ,  VOLUME , 

     USER ,  WORKDIR , ONBUILD

      1 FROM python:3.6
      2 
      3 # File Author / Maintainer
      4 MAINTAINER Qian
      5 
      6 # Update the sources list
      7 RUN apt-get update
      8 
      9 RUN apt-get install -y apt-utils
     10 #将时间区改为上海时间---东八区
     11 RUN echo "Asia/Shanghai" > /etc/timezone
     12 RUN dpkg-reconfigure -f noninteractive tzdata
     13 
     14 # Install basic applications
     15 RUN apt-get install -y vim tar git curl nano wget net-tools build-essential telnet openssh-client less netcat nmap
     16 
     17 # Install python git libraries
     18 RUN pip install gitdb
     19 RUN pip install nose
     20 RUN pip install -U mock
     21 RUN pip install gitpython
     22 
     23 # Install Netmiko
     24 # https://pynet.twb-tech.com/blog/automation/netmiko.html
     25 # RUN apt-get install -y libffi-dev libssl-dev python-yaml
     26 RUN pip install pycrypto
     27 RUN pip install utils
     28 RUN pip install --upgrade cffi
     29 RUN pip install --upgrade cryptography
     30 RUN pip install netmiko
     31 
     32 # Install node 7
     33 RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
     34 RUN apt-get install -y nodejs
     35 RUN npm install -g npm-autoinit
     36 RUN npm config set onload-script npm-autoinit/autoinit
     37 
     38 # Install ciscoparse
     39 # https://www.npmjs.com/package/ciscoparse
     40 RUN npm install ciscoparse
     41 
     42 # Install ciscoconfparse (Python tool to parse cisco config)
     43 RUN pip install --upgrade ciscoconfparse
     44 
     45 # Install django
     46 RUN pip install django==1.11.7
     47 RUN pip install dj-static
     48 RUN pip install static3
     49 RUN pip install wheel
     50 
     51 # Install redis, celery
     52 RUN apt-get -y install redis-server
     53 RUN service redis-server start
     54 RUN pip install celery[redis]
     55 RUN pip install django-celery-results
     56 
     57 # Install Butterfly (xterm in browser)
     58 RUN pip install butterfly
     59 RUN pip install libsass
     60 
     61 # Install openssh
     62 RUN apt-get -y install openssh-server
     63 RUN perl -pi -e 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
     64 
     65 # Install filebrowser
     66 RUN pip install django-grappelli
     67 RUN pip install Pillow
     68 RUN pip install django-tinymce
     69 RUN pip install django-filebrowser
     70 
     71 # Import MongoDB public GPG key AND create a MongoDB list file
     72 RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
     73 RUN echo "deb http://repo.mongodb.org/apt/debian $(lsb_release -a | grep Codename: | awk '{print $2}')/mongodb-org/3.2 main" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
     74 
     75 # Update apt-get sources AND install MongoDB
     76 RUN apt-get update && apt-get install -y mongodb-org
     77 
     78 # Create the MongoDB data directory
     79 RUN mkdir -p /data/db
     80 
     81 # Install vis.js for network map visualize
     82 RUN npm install vis
     83 
     84 # Install jedha for cdp parsing
     85 RUN pip install --upgrade jedha
     86 
     87 
     88 # Install Ansible
     89 
     90 RUN echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >>  /etc/apt/sources.list
     91 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
     92 RUN apt-get update
     93 RUN apt-get install -y ansible
     94 RUN pip install ansible
     95 
     96 
     97 # Install ntc-ansible
     98 RUN perl -pi -e 's/#inventory/inventory/g' /etc/ansible/ansible.cfg
     99 RUN perl -pi -e 's/#library/library/g' /etc/ansible/ansible.cfg
    100 RUN mkdir -p /usr/share/my_modules/
    101 RUN cd /usr/share/my_modules/ && git clone https://github.com/networktocode/ntc-ansible --recursive
    102 RUN pip install jtextfsm
    103 RUN pip install terminal
    104 RUN 2to3 -w /usr/local/lib/python3.6/site-packages/texttable.py
    105 
    106 
    107 # Install Napalm
    108 RUN pip install napalm
    109 
    110 # Install django-netjsongraph
    111 RUN pip install django-netjsongraph
    112 
    113 # Install dateutils
    114 RUN pip install python-dateutil
    115 
    116 # Install Graphviz
    117 RUN apt-get -y install libssh2-1-dev
    118 RUN apt-get -y install graphviz
    119 RUN apt-get -y install graphviz-dev
    120 
    121 # Install some perl packages
    122 RUN (echo y;echo o conf prerequisites_policy follow;echo o conf commit)|cpan
    123 RUN perl -MCPAN -e 'install Net::SSLeay'
    124 RUN perl -MCPAN -e 'install LWP::Protocol::https'
    125 RUN perl -MCPAN -e 'install XML::LibXML'
    126 RUN perl -MCPAN -e 'install JSON'
    127 RUN perl -MCPAN -e 'install Net::SSH2'
    128 RUN perl -MCPAN -e 'install Net::Telnet'
    129 RUN perl -MCPAN -e 'install autovivification'
    130 RUN perl -MCPAN -e 'install XML::Simple'
    131 RUN perl -MCPAN -e 'install GraphViz2'
    132 RUN cpan -i MONGODB/MongoDB-v0.708.4.0.tar.gz
    133 
    134 # Install additional django modules and mongoDB modules
    135 RUN pip install pymongo
    136 RUN pip install django-crispy-forms
    137 RUN pip install django-braces
    138 
    139 ENTRYPOINT service redis-server start && bash
    140 
    141 EXPOSE 80 22 57575

    3.  :wq 保存dockerfile

       root@server-244 $ docker build  - <  dockerfile-django 

    ok.............

     改名字:

    docker tag image_id  image_name:TAG

  • 相关阅读:
    css的选择器
    javaScript 的变量使用
    关于外键约束
    javaScript中运算符
    css介绍和三种引入方式
    关于盒子模型
    类和类的六种关系
    DQL和DML更多操作
    javaScript的特点
    关于 让页面中的按钮 响应回车
  • 原文地址:https://www.cnblogs.com/BigStupid/p/8322134.html
Copyright © 2011-2022 走看看