# How to install packages to non-root in Dockerfile

**URL:** https://discourse.julialang.org/t/how-to-install-packages-to-non-root-in-dockerfile/107476
**Category:** Tooling
**Tags:** question, package
**Created:** [December 12, 2023, 3:28am UTC](https://discourse.julialang.org/t/how-to-install-packages-to-non-root-in-dockerfile/107476 "2023-12-12T03:28:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![elcolie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elcolie/32/205401_2.png) [@elcolie](https://discourse.julialang.org/u/elcolie)
#### Post date: [December 12, 2023, 3:28am UTC](https://discourse.julialang.org/t/how-to-install-packages-to-non-root-in-dockerfile/107476/1 "2023-12-12T03:28:15Z")

</div>

```julia
FROM julia:1.9

WORKDIR /my_folder
RUN useradd -u 1001 sarit -d /my_folder
RUN chown sarit /my_folder
USER sarit

RUN julia -e 'using Pkg; Pkg.add("Pluto", preserve=PRESERVE_DIRECT);'
RUN julia -e 'using Pkg; Pkg.add("IJulia", preserve=PRESERVE_DIRECT);'

```

It successfully build my image, but it does install for `root`. For technical reason. I would like to run `notebook` which is not allow me to run by `root`. I have to install packages to non-root aka `sarit` user.

```julia
julia> using IJulia
 │ Package IJulia not found, but a package named IJulia is available from a registry.
 │ Install package?
 │ (@v1.9) pkg> add IJulia
 └ (y/n/o) [y]:

```

How can I achieve that?

---

<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: [December 12, 2023, 7:18am UTC](https://discourse.julialang.org/t/how-to-install-packages-to-non-root-in-dockerfile/107476/2 "2023-12-12T07:18:53Z")

</div>

Everything works just fine if I copy that Dockerfile, build it, and run it. Perhaps your example is minimized a bit too much to reproduce your problem.

---

<div class="post-metadata">

### Author: ![elcolie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elcolie/32/205401_2.png) [@elcolie](https://discourse.julialang.org/u/elcolie)
#### Post date: [December 12, 2023, 1:47pm UTC](https://discourse.julialang.org/t/how-to-install-packages-to-non-root-in-dockerfile/107476/3 "2023-12-12T13:47:15Z")

</div>

Thank you for response. I found an alternative solution by using another ready-made image.

[https://hub.docker.com/layers/jupyter/datascience-notebook/julia-1.7.2/images/sha256-919e600af3ab19bc9ff4c07297852faeadecdc94af4e75ef657c9b31d7f3b9a5](https://hub.docker.com/layers/jupyter/datascience-notebook/julia-1.7.2/images/sha256-919e600af3ab19bc9ff4c07297852faeadecdc94af4e75ef657c9b31d7f3b9a5)
