美文网首页
docker--dockerfile

docker--dockerfile

作者: amazing_bing | 来源:发表于2016-10-12 12:40 被阅读0次

    docker run -i -t ubuntu /bin/bash

    root@80952d0ecfba:/# apt-get update
    root@80952d0ecfba:/# apt-get install vim
    root@80952d0ecfba:/# apt-get install git
    root@80952d0ecfba:/# apt-get install wget
    root@80952d0ecfba:/# exit

    docker ps -a

    列出最近一次启动的container

    docker top 71a95aa007f1

    查看容器运行的程序

    docker commit --author="amazing_bing@outlook.com" 71a95aa007f1 docker/test

    命令中,指定了要提交的修改过的容器的ID、目标镜像仓库、镜像名。commit提交的知识创建容器的镜像与容器的当前状态之间的差异部分,很轻量。

    docker images

    查看新创建的镜像

    docker rmi docker/test

    删除镜像文件

    docker rm docker ps -a -q

    删除所有容器

    推送自己的镜像文件

    docker login

    docker tag centos6.3-base frankzfz/centos6.3-base

    重命名自己的docker镜像名称

    docker push frankzfz/centos6.3-base:latest

    推送

    docker run -d -p 8080:5000 frankzfz/centos6.3-base

    -d 表示守护形式后台一直运行该容器

    -p 80:8080 Dockerfile 中暴露了容器的 8080 端口,将其映射到本机的 80 端口

    建立镜像文件

    Dockerfile 文件内容

    FROM ubuntu
    MAINTAINER amazing_bing@outlook.com
    
    WORKDIR /tmp
    
    COPY xunfeng.zip /tmp/xunfeng.zip
    
    RUN apt-get update
    RUN apt-get -y install gcc libssl-dev libffi-dev python-dev libpcap-dev 
    RUN apt-get -y install wget git unzip && apt-get -y install python 
    RUN wget https://sec.ly.com/mirror/mongodb-linux-x86_64-ubuntu1604-3.4.0.tgz 
    RUN tar zxvf mongodb-linux-x86_64-ubuntu1604-3.4.0.tgz 
    RUN mv mongodb-linux-x86_64-ubuntu1604-3.4.0 /home/mongo 
    RUN unzip /tmp/xunfeng.zip && wget https://sec.ly.com/mirror/get-pip.py --no-check-certificate 
    RUN mv /tmp/xunfeng/ /home/ && python get-pip.py && pip install -U pip 
    RUN pip install pymongo Flask xlwt paramiko 
    CMD ["/bin/echo","TZ\='Asia/Shanghai'\; export TZ >> ~/.bash\_profile"]
    RUN /home/mongo/bin/mongod --port 65521 --dbpath /mnt/ & 
    RUN /home/mongo/bin/mongorestore -h 127.0.0.1 --port 65521 -d /home/xunfeng/db 
    
    ENTRYPOINT ["/bin/bash","home/xunfeng/Run.sh"]
    
    #EXPOSE 80
    
    

    docker build -t bing/xunfeng:1.0 .

    生成镜像

    java image:
    docker build -t Bing/java .
    
    buildfile:
    FROM bing/ubuntu:14.04
    MAINTAINER bing <amazing_bing@outlook.com>
    #disable interactive functions
    ENV DEBIAN_FRONTEND noninteractive
    ADD hello.sh /bin/hello.sh
    RUN /bin/hello.sh
    ENV http_proxy=http:///xxx
    RUN curl http://baidu.com
    #set default java environment variable
    ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
    RUN apt-get install -y software-properties-common && \
    add-apt-repository ppa:openjdk-r/ppa -y && \
    apt-get update && \
    apt-get install -y --no-install-recommends openjdk-8-jre && \
    rm -rf /var/lib/apt/lists/*
    
    #####################################
    ubuntu+java+tomcat+ssh
    
    buildfile:
    FROM ubuntu
    MAINTAINER tomcat "amazing_bing@outlook.com"
    #update source,install ssh sever
    RUN echo "dep http://archive.ubuntu.com/ubuntu precise main universe"> /etc/apt/sources.lists
    RUN apt-get update
    RUN apt-get install -y openssh-server
    RUN mkdir -p /var/run/sshd
    #set root ssh password of remote login is 123456
    RUN echo "root:123456" | chpasswd
    #add orache java7 source, once install to vim,wget,curl,java7,tomcat
    RUN apt-get install python-software-properties
    RUN add-apt-repository ppa:webupd8team/java
    RUN apt-get update
    RUN apt-get install -y vim wget curl oracle-java7-installer tomcat7
    #set JAVA_HOME environment variable
    RUN update-alternatives --display java
    RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle">>/etc/environment
    RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle">>/etc/default/tomcat7
    #container need to open port 22
    EXPOSE 22
    EXPOSE 8080
    #set tomcat7 init to run,SSH terminal services as a background operation
    ENTRYPOINT service tomcat7 start && /usr/sbin/sshd -D
    
    

    supervisor.conf

    相关文章

      网友评论

          本文标题:docker--dockerfile

          本文链接:https://www.haomeiwen.com/subject/gbriyttx.html