docker安装使用

安装docker
yum -y install docker


设置开机自启动并开启服务
[root@k8s-master ~]# chkconfig docker on
[root@k8s-master ~]# service docker start






启动docker后台服务
service docker start




测试运行 hello-world


[root@runoob ~]#docker run hello-world


docker pull julienstroheker/pythonflask






[root@docker ~]# setenforce 0
[root@docker ~]# sudo docker run  -v $PWD/myapp:/usr/src/myapp  -w /usr/src/myapp python:3.5 python abc.py
Traceback (most recent call last):
  File "abc.py", line 1, in <module>
    from flask import Flask,render_template,request
ImportError: No module named 'flask'
                                                              0                    [OK]
[root@docker ~]# docker search python
INDEX       NAME                                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/python                               Python is an interpreted, interactive, obj...   2543      [OK]       
docker.io   docker.io/django                               Django is a free web application framework...   630       [OK]       
docker.io   docker.io/pypy                                 PyPy is a fast, compliant alternative impl...   125       [OK]       
docker.io   docker.io/kaggle/python                        Docker image for Python scripts run on Kaggle   84                   [OK]
docker.io   docker.io/amazon/aws-eb-python                 AWS Elastic Beanstalk Python Image              18                   
docker.io   docker.io/centos/python-35-centos7             Platform for building and running Python 3...   18                   
docker.io   docker.io/resin/raspberrypi3-python            The Python buildpack image for Python apps...   14                   
docker.io   docker.io/iron/python                          Tiny Python Microcontainer                      8                    
docker.io   docker.io/centos/python-27-centos7             Platform for building and running Python 2...   7                    
docker.io   docker.io/circleci/python                      Python is an interpreted, interactive, obj...   5                    
docker.io   docker.io/resin/raspberrypi3-alpine-python     The Python buildpack image for Python apps...   4                    
docker.io   docker.io/centos/python-34-centos7             Platform for building and running Python 3...   2                    
docker.io   docker.io/komand/python-plugin                 Komand Python SDK                               2                    [OK]
docker.io   docker.io/resin/beaglebone-black-python        The Python buildpack image for Python apps...   2                    
docker.io   docker.io/qbtrade/python                       python 3.5.0 with requirements                  0                    
docker.io   docker.io/resin/artik10-alpine-python          The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/artik10-python                 The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/artik5-python                  The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/artik710-python                The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/beaglebone-green-wifi-python   The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/nitrogen6x-python              The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/odroid-c1-python               The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/qemux86-64-python              The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/qemux86-alpine-python          The Python buildpack image for Python apps...   0                    
docker.io   docker.io/resin/qemux86-python                 The Python buildpack image for Python apps...   0                    
[root@docker ~]# docker search pythonflask
INDEX       NAME                                                DESCRIPTION               






sudo docker run  -p 5001:9999 -v $PWD/myapp:/usr/src/myapp  -w /usr/src/myapp julienstroheker/pythonflask python abc.py      




docker ps -a
docker ps -l
docker ps  
















mkdir /dockerfile






vi dockerfile


FROM python:3.5
ADD . /dockerfile
WORKDIR /dockerfile
RUN pip install -r requirements.txt
RUN python abc.py










vi requirements.txt
flask
redis






docker build -t python_re .


docker images


docker tag python_re sumourn/python_re


docker push sumourn/python_re

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值