2
votes

I have been using Julia v0.4.5 for some time now along with IJulia. I am now trying to set up a Docker container in which I can run the code in one of my .jl files. To set up a working Julia inside a container I have copied the code in this Dockerfile: https://hub.docker.com/r/julialang/julia/~/dockerfile/

Using the above I get julia to work from my terminal with the command

docker run -i -t larajordan/juliatest:0.3

and then when the container opens I use the command

julia

to open Julia from the container's terminal. When using the Julia REPL I usually just execute the below command to run a .jl file. When I try this from the julia REPL inside the container however, it does not work and gives the below error message.

julia> include("/home/lara/SourceCode/researchhpc/wind_spacer/julia_learning/variables.jl")
ERROR: could not open file /home/lara/SourceCode/researchhpc/wind_spacer/julia_learning/variables.jl
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:320

I'm pretty sure that this is because the container is looking within itself for the .jl file and obviously this file doesn't exist within the container. I have tried to find out how to copy my .jl file into the contianer but it doesn't seem to work. The method I have tried is the following, from outside the container:

docker cp filename.jl /var/lib/docker/aufs/mnt/<full docker contianer id>/root/filename.jl

I get the error

cp: cannot create regular file ‘/var/lib/docker/devicemapper/mnt/a2c36e7f6f08c345a668550974a575384b5a3d465f411d3589bd5a6ac0fad13d/rootfs/root’: No such file or directory

Another thing I think will cause a problem once I get the .jl file inside the container is that the .jl file uses the command 'using '. These packages are not added to Julia or available inside the container either. I'll have to add them to the container's version of Julia. This can be done from the Dockerfile if the one I'm using is anything to go by; it seems like IJulia package is added and built within the Dockerfile with the below commands.

RUN /opt/julia/bin/julia -e 'Pkg.add("IJulia")'
RUN /opt/julia/bin/julia -e 'Pkg.build("IJulia")'

Any help on getting packages to be added from within the Dockerfile and also getting .jl files to run from the Julia REPL inside a container or just to run from the terminal inside the container would be appreciated.

1

1 Answers

2
votes

you have to mount the host dir in a container https://docs.docker.com/engine/userguide/containers/dockervolumes/#mount-a-host-directory-as-a-data-volume
try

docker run -it -v /home/lara/SourceCode/researchhpc/wind_spacer/julia_learning:/opt/julia_learning larajordan/juliatest:0.3 

then run in your REPL

julia> include("/opt/julia_learning/variables.jl")