docker--dockerfile

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

列出最近一次啟動(dòng)的container

docker top 71a95aa007f1

查看容器運(yùn)行的程序

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

命令中,指定了要提交的修改過(guò)的容器的ID、目標(biāo)鏡像倉(cāng)庫(kù)、鏡像名。commit提交的知識(shí)創(chuàng)建容器的鏡像與容器的當(dāng)前狀態(tài)之間的差異部分,很輕量。

docker images

查看新創(chuàng)建的鏡像

docker rmi docker/test

刪除鏡像文件

docker rm docker ps -a -q

刪除所有容器

推送自己的鏡像文件

docker login

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

重命名自己的docker鏡像名稱(chēng)

docker push frankzfz/centos6.3-base:latest

推送

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

-d 表示守護(hù)形式后臺(tái)一直運(yùn)行該容器

-p 80:8080 Dockerfile 中暴露了容器的 8080 端口,將其映射到本機(jī)的 80 端口

建立鏡像文件

Dockerfile 文件內(nèi)容

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Docker — 云時(shí)代的程序分發(fā)方式 要說(shuō)最近一年云計(jì)算業(yè)界有什么大事件?Google Compute Engi...
    ahohoho閱讀 15,876評(píng)論 15 147
  • docker基本概念 1. Image Definition 鏡像 Image 就是一堆只讀層 read-only...
    慢清塵閱讀 9,022評(píng)論 1 21
  • Docker 常用的一些命令 #docker run -i -t ubuntu /bin/bash root@80...
    amazing_bing閱讀 3,628評(píng)論 0 0
  • 體驗(yàn)入 今天一天都沒(méi)怎么歇就中午吃飯的時(shí)間,忙忙碌碌的一天非??炀瓦^(guò)去了,感覺(jué)時(shí)間不夠用,太充實(shí)了。 找核心 人...
    微笑你我他閱讀 137評(píng)論 0 2
  • 立秋,21:30 三兩知己談性正濃, 父親的電話(huà)急催…… 匆匆趕回家, 母親渾身抖成一團(tuán)…… 安心得睡覺(jué),是個(gè)莫...
    過(guò)客閑話(huà)閱讀 336評(píng)論 7 1

友情鏈接更多精彩內(nèi)容