2017-05-28 2 views
0

Ich versuche, diesen Workflow von isomorphic app dockerisieren. Ich baue den Container der unteren Docker-Datei.Get Python und reagieren Komponente basierte Container zu arbeiten

FROM python:3.5-slim 

RUN apt-get update && \ 
    apt-get -y install gcc mono-mcs && \ 
     apt-get -y install vim && \ 
     apt-get -y install nano && \ 
      rm -rf /var/lib/apt/lists/* 

RUN mkdir -p /statics/js 

VOLUME ["/statics/"] 

WORKDIR /statics/js 

COPY requirements.txt /opt/requirements.txt 

RUN pip install -r /opt/requirements.txt 

EXPOSE 8080 

CMD ["python", "/statics/js/app.py"] 

und dies war das Ergebnis:

$ docker build -t ciasto/pythonreact:v2 . 
Sending build context to Docker daemon 1.327 MB 
Step 1/9 : FROM python:3.5-slim 
---> b27a94c44674 
Step 2/9 : RUN apt-get update &&  apt-get -y install gcc mono-mcs &&  apt-get -y install vim && apt-get -y install nano &&  rm -rf /var/lib/apt/lists/* 
---> Using cache 
---> c76cb348707c 
Step 3/9 : RUN mkdir -p /statics/js 
---> Using cache 
---> 2ef5b24f551c 
Step 4/9 : VOLUME /statics/ 
---> Using cache 
---> 5e62c6af1867 
Step 5/9 : WORKDIR /statics/js 
---> Using cache 
---> a5a018e8c727 
Step 6/9 : COPY requirements.txt /opt/requirements.txt 
---> Using cache 
---> 1fa4dccc6608 
Step 7/9 : RUN pip install -r /opt/requirements.txt 
---> Running in 8845a0efcee7 
Collecting TurboGears2==2.3.10 (from -r /opt/requirements.txt (line 1)) 
    Downloading TurboGears2-2.3.10.tar.gz (176kB) 
Collecting Kajiki==0.6.3 (from -r /opt/requirements.txt (line 2)) 
    Downloading Kajiki-0.6.3.tar.gz (174kB) 
Collecting tgext.webassets==0.0.2 (from -r /opt/requirements.txt (line 3)) 
    Downloading tgext.webassets-0.0.2.tar.gz 
Collecting dukpy==0.1.0 (from -r /opt/requirements.txt (line 4)) 
    Downloading dukpy-0.1.0.tar.gz (2.0MB) 
Collecting WebOb>=1.2 (from TurboGears2==2.3.10->-r /opt/requirements.txt (line 1)) 
    Downloading WebOb-1.7.2-py2.py3-none-any.whl (83kB) 
Collecting crank<0.9.0,>=0.8.0 (from TurboGears2==2.3.10->-r /opt/requirements.txt (line 1)) 
    Downloading crank-0.8.1.tar.gz 
Collecting repoze.lru (from TurboGears2==2.3.10->-r /opt/requirements.txt (line 1)) 
    Downloading repoze.lru-0.6.tar.gz 
Collecting MarkupSafe (from TurboGears2==2.3.10->-r /opt/requirements.txt (line 1)) 
    Downloading MarkupSafe-1.0.tar.gz 
Collecting nine (from Kajiki==0.6.3->-r /opt/requirements.txt (line 2)) 
    Downloading nine-1.0.0-py2.py3-none-any.whl 
Collecting webassets (from tgext.webassets==0.0.2->-r /opt/requirements.txt (line 3)) 
    Downloading webassets-0.12.1.tar.gz (179kB) 
Collecting cssmin (from tgext.webassets==0.0.2->-r /opt/requirements.txt (line 3)) 
    Downloading cssmin-0.2.0.tar.gz 
Building wheels for collected packages: TurboGears2, Kajiki, tgext.webassets, dukpy, crank, repoze.lru, MarkupSafe, webassets, cssmin 
    Running setup.py bdist_wheel for TurboGears2: started 
    Running setup.py bdist_wheel for TurboGears2: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/51/1d/bb/c9cfdcf2a49f71955d5b66aed0dbd187e58e5d77a9fa34a4af 
    Running setup.py bdist_wheel for Kajiki: started 
    Running setup.py bdist_wheel for Kajiki: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/ad/fe/15/33e02c73fead4ea9238fcd31d273accf6fb9d922ec901e20c8 
    Running setup.py bdist_wheel for tgext.webassets: started 
    Running setup.py bdist_wheel for tgext.webassets: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/00/f2/09/0378f24bd9151b7a927093546c11685899ebec451b65eb181f 
    Running setup.py bdist_wheel for dukpy: started 
    Running setup.py bdist_wheel for dukpy: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/21/29/46/34c303b9dca370a8ccc97a84b094c8089b78edde125b0a1fcb 
    Running setup.py bdist_wheel for crank: started 
    Running setup.py bdist_wheel for crank: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/1c/00/54/4dcfd62d8268d7b34ea607bd9f8cb12aa930a7718c8c5fbc02 
    Running setup.py bdist_wheel for repoze.lru: started 
    Running setup.py bdist_wheel for repoze.lru: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/b2/cd/b3/7e24400bff83325a01d492940eff6e9579f553f33348323d79 
    Running setup.py bdist_wheel for MarkupSafe: started 
    Running setup.py bdist_wheel for MarkupSafe: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57 
    Running setup.py bdist_wheel for webassets: started 
    Running setup.py bdist_wheel for webassets: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/9d/cb/c2/340b9b695822b6954840bcb6cd147b3a7cfc2bcd922296e63e 
    Running setup.py bdist_wheel for cssmin: started 
    Running setup.py bdist_wheel for cssmin: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/c3/79/88/647f59be446af4e9867362ca6e961cc7f218bd793fbdc351a6 
Successfully built TurboGears2 Kajiki tgext.webassets dukpy crank repoze.lru MarkupSafe webassets cssmin 
Installing collected packages: WebOb, crank, repoze.lru, MarkupSafe, TurboGears2, nine, Kajiki, webassets, cssmin, tgext.webassets, dukpy 
Successfully installed Kajiki-0.6.3 MarkupSafe-1.0 TurboGears2-2.3.10 WebOb-1.7.2 crank-0.8.1 cssmin-0.2.0 dukpy-0.1.0 nine-1.0.0 repoze.lru-0.6 tgext.webassets-0.0.2 webassets-0.12.1 
---> 86c189792ae7 
Removing intermediate container 8845a0efcee7 
Step 8/9 : EXPOSE 8080 
---> Running in 9243a87c36e2 
---> e7d35d54e66d 
Removing intermediate container 9243a87c36e2 
Step 9/9 : CMD python /statics/js/app.py 
---> Running in 6e3b53cd901d 
---> 0d79c4f81f3b 
Removing intermediate container 6e3b53cd901d 
Successfully built 0d79c4f81f3b 

Also meine erste Frage ist, was die Stufe 9 Mittel tut? bedeutet das, dass es versucht, den /statics/js/app.py Pfad noch vor dem Ausführen des Containers auszuführen, da das nicht funktionieren würde, da ich plante, dieses statics Volume von der host zu mounten. Zweitens, wenn ich den Befehl ausführen:

$ docker run -it -v ~/Development/my-Docker-builds/pythonReact/statics/:/statics/ -d ciasto/pythonreact:v2 

03d77c87651e752450e3be0aa64a0841c088b32a1db5424ad96c150c949d0366

ich die Raute-Taste, aber nichts funktioniert! Ich sehe nicht einmal die Start-Trace oder Fehlermeldung von app.py hatte einen Fehler.

Also wie sollte ich die app.py von Host montierten Volume ausführen, wenn ich den Container ausführen?

+1

Es tut, was Sie es gesagt haben: 'CMD [" python "," /statics/js/app.py "]' – jonrsharpe

+0

aber wenn ich versuche, Seite bei 'localhost: 8080' zu öffnen, bekomme ich nichts –

+0

Wann Sie geben nicht den externen Port an, der zufällig ausgewählt wird. Fügen Sie dem Befehl run '-p 8080' hinzu. – jonrsharpe

Antwort

0

Sie können CMD als Startskript für den Container betrachten. Nachdem Sie gesagt haben, dass in Schritt 9 nur pyhton /statics/js/app.py markiert ist, wird es ausgeführt, wenn Sie den Container starten. da Sie -d Flagge Auch verwenden, werden Sie nicht in der Lage sein, Protokolle, um zu sehen, so dass Sie sie mit docker logs Befehl zu holen haben, wie:

docker logs 03d77c87651e752450e3be0aa64a0841c088b32a1db5424ad96c150c949d0366 

Die Protokolle genug sein, sollten Sie das Problem helfen herauszufinden. Ich hoffe, es hilft.

Verwandte Themen