Presently I have three files that are referenced in my docker script. I’ll provide the docker script and then the miscellaneous files.
Dockerfile
# src: https://techytok.com/from-zero-to-julia-using-docker/
FROM julia:latest
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
apt-utils gcc g++ openssh-server cmake build-essential \
gdb gdbserver rsync vim locales
RUN apt-get install -y bzip2 wget gnupg dirmngr apt-transport-https \
ca-certificates tmux && \
apt-get clean
# setup ssh
RUN mkdir /var/run/sshd && \
echo 'root:my_password' |chpasswd && \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config && \
mkdir /root/.ssh
# remove leftovers
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Expose 22 for ssh server. 7777 for gdb server
EXPOSE 22 7777
# add user for debugging
RUN useradd -ms /bin/bash debugger
RUN echo 'debugger:my_password' | chpasswd
# start server
CMD ["/usr/sbin/sshd", "-D"]
# add support for English
COPY locale.gen /etc/locale.gen
RUN locale-gen
# add julia packages
COPY install.jl /etc/install.jl
RUN julia /etc/install.jl
install.jl
using Pkg
pkg"add DataFrames"
pkg"add GLM"
pkg"add LinearAlgebra"
pkg"add Statistics"
pkg"add LaTeXStrings"
pkg"add Random"
pkg"add Distributions"
pkg"add StaticGraphs"
pkg"add GraphPlot"
pkg"add LightGraphs"
pkg"add Colors"
pkg"add Plots"
pkg"precompile"
locale.gen
en_US.UTF-8 UTF-8
Built the container with the following command
sudo docker build -t julia-container .
Finally, I used VSCode to spin up the instance and attach to it. I could run lines that didn’t require any packages but if I tried to run
using Plots
Then I got an error asking me to do using Pkg; Pkg.add("Plots")
(Eventually I’d like to get to where I can host a jupyter notebook hosting Julia on docker and access it from my computer but figuring out the basics is proving to be ambitious haha)