2017-10-17 1 views
0

W ährend der Kolben Anwendung innerhalb virtualenv python3 -m venv FLSK-ENVWarum werden Docker Container Bilder so groß, während deplying python3.6, virtualenv, Glaskolben, Gunicorn auf UBUNTU 16.04

Dockerfile bereitstellen:

FROM appcontainers/ubuntu:xenial 

    MAINTAINER user <user> 

    RUN apt-get install -y software-properties-common \ 
      && add-apt-repository ppa:jonathonf/python-3.6 -y \ 
      && apt-get update -y \ 
      && apt-get install -y python3.6-minimal python3.6-venv \ 
      && apt-get install -y git \ 
      && apt-get install python-pip -y \ 
      && pip install --upgrade pip \ 
      && pip install gunicorn \ 
      && mkdir -p /home/EZMOVE 

    WORKDIR /home/workdir 

    RUN git clone -b develop --single-branch http://repo 

    RUN ["chmod", "+x", "./prepareenv.sh"] 

    RUN /bin/bash -c "source prepareenv.sh" 

    EXPOSE 5000 

So oben dockerfile wird das minimale Ubuntu-16.04 aus "appcontainers/ubuntu: xenial" ziehen und nur erforderliche Pakete wie:

aktualisieren und installieren

Dann wird es die ‚prepareenv.sh‘ führt die python3.6 virtuelle Umgebung zu erstellen, aktiviert Venv und dann installieren requirements.txt pip verwendet, dann wird es den Port aussetzen und gunicorn die Flasche Anwendung serv. .etc.

Aber während das Bild erstellt wird, vergrößert sich die Docker-Bildgröße von 70MB auf 550MB.

während der Installation der Pakete ist die Installation der anderen Pakete wie wie folgt:

The following additional packages will be installed: 
    binutils build-essential bzip2 cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc 
    gcc-5 gcc-5-base libalgorithm-diff-perl libalgorithm-diff-xs-perl 
    libalgorithm-merge-perl libasan2 libatomic1 libc-dev-bin libc6 libc6-dev 
    libcc1-0 libcilkrts5 libdpkg-perl libexpat1-dev libfakeroot 
    libfile-fcntllock-perl libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 
    libmpc3 libmpfr4 libmpx0 libpython-all-dev libpython-dev libpython-stdlib 
    libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib 
    libquadmath0 libstdc++-5-dev libstdc++6 libtsan0 libubsan0 linux-libc-dev 
    make manpages manpages-dev python python-all python-all-dev python-dev 
    python-minimal python-pkg-resources python-setuptools python-wheel python2.7 
    python2.7-dev python2.7-minimal 
Suggested packages: 
    binutils-doc bzip2-doc cpp-doc gcc-5-locales debian-keyring g++-multilib 
    g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib autoconf automake 
    libtool flex bison gdb gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg 
    libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg 
    libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc locales 
    libstdc++-5-doc make-doc man-browser python-doc python-tk 
    python-setuptools-doc python2.7-doc binfmt-support 
The following NEW packages will be installed: 
    binutils build-essential bzip2 cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc 
    gcc-5 libalgorithm-diff-perl libalgorithm-diff-xs-perl 
    libalgorithm-merge-perl libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 
    libcilkrts5 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl 
    libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpfr4 libmpx0 
    libpython-all-dev libpython-dev libpython-stdlib libpython2.7 
    libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib libquadmath0 
    libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev make manpages manpages-dev 
    python python-all python-all-dev python-dev python-minimal python-pip 
    python-pkg-resources python-setuptools python-wheel python2.7 python2.7-dev 
    python2.7-minimal 
The following packages will be upgraded: 
    gcc-5-base libc6 libstdc++6 
3 upgraded, 59 newly installed, 0 to remove and 24 not upgraded. 
Need to get 76.6 MB of archives. 
After this operation, 210 MB of additional disk space will be used. 

So wie das Bild Größe Docker zu reduzieren?

+0

[Siehe meine Antwort auf eine ähnliche Frage] (https://stackoverflow.com/questions/24394243/why-are-docker-container-images-so-large/39078793#39078793) – Munchkin

Antwort

1

Versuchen Sie, die folgenden Dockerfile, es wird die Größe des Bildes bis zu 255 MB. "--no-install-empfiehlt" stellt sicher, dass nur die benötigten Pakete installiert sind und "rm -rf/var/lib/apt/lists/*" bereinigt einschließlich Indexdateien.

FROM appcontainers/ubuntu:xenial 

RUN apt-get update \ 
      && apt-get install -y --no-install-recommends software-properties-common \ 
      && add-apt-repository -y ppa:jonathonf/python-3.6 \ 
      && apt-get update \ 
      && apt-get install -y --no-install-recommends python3.6-minimal python3.6-venv \ 
      && apt-get install -y --no-install-recommends git \ 
      && apt-get install -y --no-install-recommends python-pip \ 
      && pip install --upgrade pip \ 
      && pip install gunicorn \ 
      && rm -rf /var/lib/apt/lists/* \ 
      && mkdir -p /home/EZMOVE 

WORKDIR /home/workdir 

EXPOSE 5000 
+0

Dank #Dino , ich das zusätzliche Argument 'apt-get install -y --no-install-empfiehlt' hinzugefügt, so dass einige, wie es die Größe von Ubunut 16.04 docker Behälter von 550MB auf 210MB reduziert. so plane ich für diese so, mit Gunicorn Kolben Anwendung hosten Wie kann ich den Docker Behälter optimiert, wie 1. nur binär von Kolben App in den Behälter hinzufügen, so dass für diese brauche ich nicht Python-dev wie zu installieren Pakete. 2. Während die viele Docker Behälter zu schaffen Schichten erstellt werden geting so wie kann ich alle vorherige Schicht in einzelne Schicht verschmelzen. – Dhairya

Verwandte Themen