https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/
FROM python:3.7
RUN mkdir /app
WORKDIR /app
ADD . /app/
RUN pip install -r requirements.txt
EXPOSE 5000
CMD ["python", "/app/main.py"]
- Get the official Python Base Image for version 3.7 from Docker Hub.
- In the image, create a directory named app.
- Set the working directory to that new app directory.
- Copy the local directory’s contents to that new folder into the image.
- Run the pip installer (just like we did earlier) to pull the requirements into the image.
- Inform Docker the container listens on port 5000.
- Configure the starting command to use when the container starts.
docker build -f Dockerfile -t hello-python:latest .
docker run -p 5001:5000 hello-python
Running in Kubernetes
install kubernetes,
brew install kubectl
No comments:
Post a Comment