Dockerfile自定义镜像-----push仓库,处处运行

一:docker入门操作
docker概念
Docker是Docker.Inc公司开源的一个基于轻量级虚拟化技术的容器引擎项目,整个项目基于Go语言开发, 遵从Apache 2.0协议。
container: run起来得image即容器。
容器、镜像、仓库基本操作:
下面是我在project中用到得action:

docker基本操作
docker login
docker search
docker pull
docker load
docker build -t xxxx .
docker tag
docker images
docker rmi
docker ps
docker run -tid image /bin/bash
docker exec -ti container /bin/bash
docker commit
docker push

二:如下dockerfile内容是RF得运行环境及java得运行环境。
dockerfile中尽量不要出现太多RUN 因为镜像是一层一层构建,如果层太多会导致镜像特别大。同一个内容,别人制作出来得镜像可能百十兆,而你构建出来得可能是几个G,亲测有效。

FROM centos:7.6.1810
#维护人信息
MAINTAINER The Ecs Automation Project <131****@163.com>
ENV PATH $PATH:/usr/local/python3/bin/
ENV PYTHONIOENCODING utf-8
RUN set -ex \
  && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
  && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
  && yum makecache \
  && sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
  && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \
  && yum clean all \
  && mkdir /usr/local/python3 \
  && wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz \
  && tar -xvJf  Python-3.6.8.tar.xz && rm -f Python-3.6.8.tar.xz \
  && cd Python-3.6.8 \
  && ./configure prefix=/usr/local/python3 \
  && make && make install \
  && cd .. \
  && pip3 --default-timeout=1000 install --upgrade pip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
  && pip3 --default-timeout=1000 install --upgrade setuptools -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
  && pip3 --default-timeout=1000 install robotframework-selenium2library -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
  && pip3 --default-timeout=1000 install robotframework -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
##&& pip3 --default-timeout=1000 install robotframework-ride==1.5.2.1 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
##&&  && pip3 --default-timeout=1000 install pyvirtualdisplay -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
  && pip3 --default-timeout=1000 install robotframework-pabot -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
    && cd /etc/yum.repos.d/ \
  && yum -y install firefox \
    && firefox --version
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz \
  && tar -zxf geckodriver-v0.24.0-linux64.tar.gz \
    && mv geckodriver  /usr/local/bin \
    && firefox --version \
    && cd /etc/ \
    && echo "xx.xx.xx.xx 域名" >> hosts \
    && echo "xx.xx.xx.xx 域名" >> hosts \
    && echo "xx.xx.xx.xx 域名" >> hosts \
    && echo "xx.xx.xx.xx 域名" >> hosts
#安装httpd软件包
RUN yum -y update \
  && yum -y install httpd \
  && wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm \
  && chmod +x jdk-8u131-linux-x64.rpm \
  && rpm -ivh jdk-8u131-linux-x64.rpm
#CMD ["usr","bin","bash"]

你可能感兴趣的:(docker)