48 lines
1.4 KiB
Markdown
48 lines
1.4 KiB
Markdown
# Python-3.9 Docker Container
|
|
|
|
Python-3.9 alpine linux image with added files used by my standard cronjob scripts. Dummy ssh keys are included. Replace in actual project if needed. This container includes ssh, mysql, read/write xls/xlsx and the pudb python debugger.
|
|
|
|
This contianer will run the scrpipt named `script.py`.
|
|
|
|
How install [docker](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04) and [docker-compose](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04).
|
|
|
|
## To only Build container
|
|
```
|
|
docker-compose Build
|
|
```
|
|
|
|
## To Build (if needed) and Run contianer
|
|
```
|
|
docker-compose up
|
|
```
|
|
|
|
## To Build (if needed) and Run container in background
|
|
```
|
|
docker-compose up -d
|
|
```
|
|
|
|
## To Run container with command prompt
|
|
```
|
|
docker-compose run --entrypoint=/bin/sh python-app
|
|
```
|
|
|
|
## To enter running container with command prompt
|
|
```
|
|
docker-compose exec --entrypoint=/bin/sh python-app
|
|
```
|
|
|
|
## To view container logs
|
|
```
|
|
docker-compose logs python-app
|
|
```
|
|
|
|
## To monitor container logs (when container started with -d)
|
|
```
|
|
docker-compose logs -f python-app
|
|
```
|
|
|
|
# Customzing for your own app
|
|
Replace the contents of the `app` folder with your python script(s). If the main script is named `script.py` no additonal changes are needed.
|
|
|
|
If your script has a different name then modify the last line of `docker-compose.yml` and change `entrypoint` to reference your script.
|