This repository contains a simple boilerplate code and configuration to help you quickly set up a Python project to run within a Docker container. Docker allows you to create isolated environments for your Python applications, making it easier to manage dependencies and ensure consistency across different systems.
Before using this boilerplate, ensure you have the following software installed on your system:
Follow these steps to set up your Python project within a Docker container:
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/python-docker-boilerplate.git
-
Navigate to the project directory:
cd python-docker-boilerplate
-
Place your Python application code or scripts in the
app
directory. You can modify theDockerfile
to specify the Python version or add any additional dependencies required for your application. -
Build the Docker image:
docker build -t python-docker-app .
This will create a Docker image named
python-docker-app
. -
Run the Docker container:
docker run -it python-docker-app
Your Python application will now run within the Docker container.
If you have a more complex setup or need to run multiple containers, you can use Docker Compose. The docker-compose.yml
file in this repository is pre-configured to run the Python container.
-
Make sure you are in the project directory and run:
docker-compose up
This will start the Python container as defined in the
docker-compose.yml
file.
-
The
app
directory is mounted as a volume in the Docker container. This allows you to make changes to your code without rebuilding the image. -
The example code in the
app
directory is a simple "Hello, World!" script. Replace it with your Python code. -
Customize the Dockerfile and
requirements.txt
file to install any additional dependencies your project requires.
Feel free to contribute to this boilerplate by opening issues or pull requests. Your feedback and improvements are welcome.
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! 🐍🐳