Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eitancj/python_in_docker
Playing around with docker images, python and streamlit
https://github.com/eitancj/python_in_docker
container-image containerization docker dockerfile python python3 streamlit
Last synced: about 1 month ago
JSON representation
Playing around with docker images, python and streamlit
- Host: GitHub
- URL: https://github.com/eitancj/python_in_docker
- Owner: eitancj
- Created: 2023-08-01T20:43:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-11T14:29:27.000Z (over 1 year ago)
- Last Synced: 2023-09-11T15:45:03.293Z (over 1 year ago)
- Topics: container-image, containerization, docker, dockerfile, python, python3, streamlit
- Language: Python
- Homepage:
- Size: 1.01 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Using Docker to Containerize a Python App
![](https://github.com/eitancj/preview_images/blob/main/python_in_docker.png?raw=true)
\
Just experimenting with building Docker images.
Containerizing a Python3-Streamlit app, in this case.Inspired by [this](https://app.pluralsight.com/guides/dockerfile-for-python-web-projects) short guide which I recommend.
### Pre-installed on your machine
- Git
- Docker*A simple way to work with Docker images locally:*\
https://www.docker.com/products/docker-desktop/### Tech Stack
- Tested on macOS X
- Python 3.11.4
- Streamlit
- Debian-based container### Running the App
1. Clone git repo & cd into it
```
git clone https://github.com/eitancj/python_in_docker
cd python_in_docker
```2. Build image
```
docker build -t python_in_docker:V1 .# May take a few minutes: Streamlit is relatively heavy
```3. Verify image creation
```
docker images python_in_docker
```4. Run app
```
docker run -d --rm -p 8501:8501 --name pydock python_in_docker:V1# Make sure no other running process is using that port on your machine
```5. Test app
```
open http://localhost:8501 # will open in your default web browser# Or simply copy and paste the address into your web browser
```6. Gracefully stop (and remove) container when you're done
```
docker container stop pydock
```7. Remove the created image
```
docker rmi python_in_docker:V1
```8. Clean up local copy (unless you want to keep it)
```
cd .. && rm -rf python_in_docker# BE PRUDENT WITH 'rm -rf'.
# Make sure you're in the right directory and aiming at the right folder.
```9. That's it