Using Docker with bind mount points

Docker, https://docs.docker.com/get-started/overview, is an open platform for developing, shipping, and running applications. Docker enables separation of ‘containerised’ applications from local computing infrastructure. It’s a popular way of preparing programmes to share with others (https://hub.docker.com) and to run on remote computers also.

Using docker means not having to have complex software server applications installed locally. Instead they are run in ‘sealed’ containers, held discrete from the local computer. In an example Use Case of developing code in Python for example, a docker container holding the latest version of Python, plus the Python script can be built and run.

However, in this use case, in order to edit the Python script and rerun it, the image container needs to be rebuilt in docker each time there are changes made to the code. Docker has the ability to use ‘bind mounts’ to circumvent this for development purposes. The folder holding the source code is ‘mounted’ into the container image, meaning that the source code can then be edited and run immediately in the image without needing to be rebuilt.

A Git repo has been developed to show how to achieve this, https://github.com/SPFDigiEnv/HelloWorldDocker. To run these examples, and assuming docker is installed on the local computer, download this repo and run the docker commands in the Readme from the command line when in this local folder.

If Docker has not been used before, the initial build may take a while as the latest Python image is downloaded for the first time.

1 comment

Comments are closed.