Inspired by valudio/docker-python-flask-oracle
This docker image serves as an environment to execute python scripts with oracle database connection.
docker build -t web .
docker run -d -p 80:5000 --name web -v <host-absolute-path>:/opt/data/api web
host-absolute-path
: directory on Docker Engine's host
If you are using Docker Machine on Mac or Windows, your Docker Engine daemon has only limited access to your macOS or Windows filesystem. Docker Machine tries to auto-share your /Users (macOS) or C:\Users (Windows) directory.
On macOS:
docker run -v /Users/<path>:/<container path> ...
On Windows:
docker run -v c:\<path>:c:\<container path>
In the case of VirtualBox you need to make the host folder available as a shared folder in VirtualBox. Then, you can mount it using the Docker -v flag.
At this time Docker Machine is a virtual machine running under VirtualBox in your machine, so to expose your application port you need to map your virtual machine port to your host port.
docker-machine stop default
Option 1 - Use the VirtualBox interface
- Open VirtualBox Manager
- Select your Docker Machine VirtualBox image (e.g.: default)
- Open Settings -> Network -> Advanced -> Port Forward
- Add your app name, the desired host port (e.g.: 80) and your Guest port (e.g.: 80)
Option 2 - Use the VirtualBox command line
VBoxManage modifyvm "default" --natpf1 "web,tcp,,80,,80"
docker-machine start default