# Configuring Docker Image of Julia. Julia can't see installed packages

**URL:** <https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790>\
**Category:** New to Julia\
**Tags:** docker\
**Created:** [October 22, 2020, 3:03am UTC](https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790 "2020-10-22T03:03:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoganNielsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logannielsen/32/18858_2.png) [@LoganNielsen](https://discourse.julialang.org/u/LoganNielsen)\
**Post date:** [October 22, 2020, 3:03am UTC](https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790/1 "2020-10-22T03:03:46Z")

</div>

Presently I have three files that are referenced in my docker script. I’ll provide the docker script and then the miscellaneous files.

Dockerfile

```julia
# 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

```julia
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

```julia
en_US.UTF-8 UTF-8

```

Built the container with the following command

```julia
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

```julia
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)

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 22, 2020, 5:44am UTC](https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790/2 "2020-10-22T05:44:56Z")

</div>

Are you running the image as your `debugger` user? If so, that explains this; you install everything as `root`, so they end up in `/root/.julia/environments/...` but the `debugger` user looks in `/home/debugger/.julia/environments/...`.

---

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [October 22, 2020, 6:16am UTC](https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790/3 "2020-10-22T06:16:13Z")

</div>

Extending on the answer of @fredrikekre:  
You need to set the `JULIA_DEPOT_PATH` for your user (if it is not root).

As an example, you can take a look at the Dockerfile for Pluto:  
[https://github.com/fonsp/PlutoUtils.jl/blob/master/docker/default/Dockerfile](https://github.com/fonsp/PlutoUtils.jl/blob/master/docker/default/Dockerfile)

---

<div class="post-metadata">

**Author:** ![LoganNielsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logannielsen/32/18858_2.png) [@LoganNielsen](https://discourse.julialang.org/u/LoganNielsen)\
**Post date:** [November 1, 2020, 6:32pm UTC](https://discourse.julialang.org/t/configuring-docker-image-of-julia-julia-cant-see-installed-packages/48790/5 "2020-11-01T18:32:54Z")

</div>

Here’s what I ended up doing

```julia
FROM ubuntu:latest

RUN apt-get update && \
    apt-get install -y wget && \
    rm -rf /var/lib/apt/list/*

ENV JULIA_VERSION=1.4.1

RUN mkdir /opt/julia-${JULIA_VERSION} && \
    cd /tmp && \
    wget -q https://julialang-s3.julialang.org/bin/linux/x64/`echo ${JULIA_VERSION} | cut -d. -f 1,2`/julia-${JULIA_VERSION}-linux-x86_64.tar.gz && \
    tar xzf julia-${JULIA_VERSION}-linux-x86_64.tar.gz -C /opt/julia-${JULIA_VERSION} --strip-components=1 && \
    rm /tmp/julia-${JULIA_VERSION}-linux-x86_64.tar.gz

RUN ln -fs /opt/julia-*/bin/julia /usr/local/bin/julia

# Add packages and precompile 
RUN julia -e 'import Pkg; Pkg.update()' && \
         julia -e 'import Pkg; Pkg.add("Plots"); using Plots' && \
         julia -e 'import Pkg; Pkg.add("Distributions"); using Distributions' && \
         julia -e 'import Pkg; Pkg.add("IJulia"); using IJulia'

# Set up Jupyter    
RUN apt-get install -y build-essential python3.8 python3-pip python3-dev
RUN pip3 -q install pip --upgrade

RUN pip3 install jupyter

WORKDIR /src/notebooks

ENV TINI_VERSION v0.6.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]

```
