Docker seems to be a sophisticated way to test server applications, and to bring them in production. Docker can host various operating systems.
To have Docker on a Windows 10 system, one should have Windows Pro on hardware that supports virtualization (I guess most current hardware will support it. Here are the exact specs.)
The Docker container should eventuallu run on Azure, so I followed this tutorial. After installing Docker Desktop, it is necessary to download a basic template of a Docker container, probably most often retrieved from GitHub. So after installing GIT, I choose to download the Diango container, as mentioned in the tutorial. This has the Python and Flask software included.
The Dockerfile in this download contains the build configuration for the container. After updating the requirements.txt file for Python I tried to build the container.
However I had an error installing the pyodbc: In the end I needed a quite complicated command to have ODBC installed correctly.
FROM python:3.6
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# unixODBC
RUN apt-get update && \
apt-get install -y apt-transport-https && \
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install msodbcsql17 unixodbc-dev -y# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 8080
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
The build commando is done in a powershell prompt (don't forget the dot at the end):
PS E:\docker_prep\docker-django-webapp-linux> docker build -t mycontainer_ai .
And to run:
PS E:\docker_prep\docker-django-webapp-linux> docker run -p 8080:8080 mycontainer_ai
Geen opmerkingen:
Een reactie posten