Tools, FAQ, Tutorials:
Build and Run Python Hello Website Image
How to build a Hello Website Docker image using the Python base image? I have the Dockerfile ready.
✍: FYIcenter.com
If you have the Dockerfile ready as shown in the last tutorial,
you continue to build a new Docker image and run it.
1. Build the new image.
fyicenter$ docker image build --tag python-web . Step 1/7 : FROM python ---> a4cc999cf2aa Step 2/7 : WORKDIR /app ---> Running in 936c6b30e70a Step 3/7 : COPY . /app ---> 16af2d71c68d Step 4/7 : RUN pip install --trusted-host pypi.python.org -r package.lst ---> Running in 48985b3ba2d4 ... Installing collected packages: itsdangerous, Werkzeug, MarkupSafe, Jinja2, click, Flask, Redis Removing intermediate container 48985b3ba2d4 ---> 8eece4e03295 Step 5/7 : EXPOSE 80 ---> Running in 3521d3feecb0 Removing intermediate container 3521d3feecb0 ---> e26936f6f2cf Step 6/7 : ENV NAME World ---> Running in 6be383b38da2 Removing intermediate container 6be383b38da2 ---> d29cd293763f Step 7/7 : CMD ["python", "hello-web.py"] ---> Running in 77146103f076 Removing intermediate container 77146103f076 ---> ec5de1c15fa6 Successfully built ec5de1c15fa6 Successfully tagged python-web:latest
2. Create a container and run it.
fyicenter$ docker container run --publish 8080:80 python-web * Serving Flask app "hello-web" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://0.0.0.0:80/ (Press CTRL+C to quit) 10.0.2.4 - - "GET / HTTP/1.1" 200 - ... ^C
3. Stop the container with CTRL+C and run it again in background.
fyicenter$ docker container run --publish 8080:80 --detach python-web fyicenter$ docker container list --latest CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 7da8f1fa7fcc python-web "python hello-web.py" 6 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp
As you can see, our new Python Hello Website is started now as a Docker container.
⇒ Test Python Hello Website Container
⇐ Requirements to Python Hello Website Image
2020-08-25, 1013👍, 0💬
Popular Posts:
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
What is EPUB 3.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 3.0 Metadata "dc:publisher" ...
How to search for the first match of a regular expression using re.search()? The re.search() functio...
Where to find tutorials on PHP language? I want to know how to learn PHP. Here is a large collection...