Docker Configuration Example

Index of All Documentation » How-Tos » How-Tos for Specific Environments » Using Wing Pro with Docker »

If you are new to Docker, setting up a simple container manually may help to clarify how Docker works. This can be done by creating a directory docker and placing the following files into it.


FROM python:3.7
RUN pip install --trusted-host Flask
CMD ["python", ""]

from flask import Flask

app = Flask(__name__)

def hello():
    return "<h3>Hello World!</h3>Your app is working.<br/></br/>"

if __name__ == "__main__":'', port=80, use_reloader=True)

Then build the Docker container by typing the following in the docker directory:

docker build --tag=myapp .

You can now run your container like this:

docker run -v "/path/to/docker":/app -p 4000:80 myapp

You will need to substitute /path/to/docker with the path to the docker directory you created above; the quotes make it work if the path has spaces in it.

You can now try this tiny Flask web app by pointing a browser running on your host system at it:

If you are using Docker Desktop, then use http://localhost:4000/

If you are using Docker CE, you will need to determine the IP address of your container and use that instead of localhost. One way to do this is to type docker ps to find the Container ID for your container and then use it in the following in place of c052478b0f8a:

docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" c052478b0f8a

Notice that if you make a change to in Wing, then the change will be reflected in your browser when you reload the page. This is due to using both the -v argument for docker run to mount a volume in the container (so container files are immediately updated if they change on the host), and the fact that for Flask is being passed use_reloader=True (so that changed container files are automatically reloaded by Flask).