When running gdb in ssh take into account that if you have a prelaunchtask ,it will be run in the remote machine in this case inside the docker image which likely might not be want you want, as it was my case when I had the build and run commands for the docker image in the prelaunch task, so I need to remember to have the docker container running before moving to the debug phase.įinally you can run debug, and enjoy your bug catching from your container instance. Note that the compilation is run inside the container baser on the “bootstrap” command. in order to allow gdb to stop the program execution at the desired break points you need to run the container with the –privileged flag. Without this configuration if you just try to build and run your image and debug some code on it you will notice that the debugger will not stop at your breakpoints although you will be able to run the program inside gdb. Note the “–privileged” flag in the run command. Next we will generate a bash script in charge of building and running our container.
#Alpine install gfortran apk#
# install gdb # RUN apk add -no-cache gdb # we need make and linux-headers to compile gdb However, the resulting installation does not include GFortran I believe this means that the packaged binaries that are available do not include the GFortran front end. Examples of proceeding options: setup-lbu to configure a 'local backup' location for the diskless system, and lbu commit to then save the local configuration state. To start, I attempted to install the GNU Compiler Collection by: sudo pacman -S gcc. Installing a something that may be missing in the live system to configure the available hardware, using apk, the alpine package manager.
#Alpine install gfortran update#
In order to have our source code available at the docker container, one option is to use the COPY instruction in order to copy our source files to the container, however that implies that we will need to rebuild the container each time we update the code, a more flexible approach is to mount a volume in the container and them in the run command link it to our source path, that way our source will be synchronized between host in the container. Linux lampadas 3.9.9-1-ARCH 1 SMP PREEMPT Wed Jul 3 22:52:05 CEST 2013 i686 GNU/Linux.
#Alpine install gfortran manual#
Unfortunately ,the gdb loaded with alpine does not include gdbserver, so I have to relay on the manual compilation of gdb, although for this configuration we are not going to use the gdbserver. We will use alpine linux as the baseline of our image.
In order to later access it through ssh we need to expose the port 22.
So first we create a Dockerfile that can execute gfortran, gdb, and a ssh server with the necessary keys.
Although it will be a linux binary, in some cases this might even be desirable. One of those is to use Docker, with a simple dockerfile we can get a running and reproducible enviroment where we can compile and run our fortran program. But there are more options to debug our program. As we saw in our earlier post OSx is not very friendly to set up with the gdb.