Volumes and Shells
One way to develop applications with Docker is to mount a volume and run the build and application using a shell.
Mounting a volume means that files stored on your host machine are also accessible inside the Docker Container – by specifying the directories to mount in the Docker Compose file. Most images contain a folder that is reserved for the source code. In this instance, it shouldn’t be necessary, since you will be attaching a terminal to the container anyway. You can now edit the code using any editor installed on your host by modifying the local files.
Attach a shell to the running Docker Container using the “docker attach” command, and utilise the shell to build and run the application.
IDE inside a Container
Another great alternative is to install the IDE inside the Docker Container. You can then launch the IDE and use it to edit, build and execute your code. This approach, however, requires you to have X11 forwarding working. On Linux, this works out of the box. On Windows, you will need to install an X11 server (e.g. Xming) and configure the appropriate display inside the container: export DISPLAY=192.168.0.2:0. Your actual IP address and display number will, of course, depend on your specific setup.
Using the Image for Continuous Integration (CI)
Ideally, you would use the same Docker Image for CI. By employing only one image for both development and CI, you will ensure that the environment is always up-to-date and that the code works for all developers.