patterndockerMinor
How/where are programs installed in Docker containers?
Viewed 0 times
aredockerwhereprogramshowcontainersinstalled
Problem
Apologies for being such a basic question but all the resources I've found seem to take this knowledge for granted.
I'm brand new to docker and containerization in general.
Today when opening a program for a project i.e. RStudio, Jupyter, Notebook, Spyder or an IPython Console I would run a bash script in anaconda3/bin, either from a custom menu item or Anaconda Navigator or just the terminal.
How does this work with Docker? If I'm using a Docker container for my project and I install Anaconda and the other packages I use, is there a folder within the container containing the bash scripts or does it link to bash scripts installed on my system or something else?
I'm brand new to docker and containerization in general.
Today when opening a program for a project i.e. RStudio, Jupyter, Notebook, Spyder or an IPython Console I would run a bash script in anaconda3/bin, either from a custom menu item or Anaconda Navigator or just the terminal.
How does this work with Docker? If I'm using a Docker container for my project and I install Anaconda and the other packages I use, is there a folder within the container containing the bash scripts or does it link to bash scripts installed on my system or something else?
Solution
Hi and welcome to DevOps SE and Docker!
Now the concept of Docker is to create isolated virtual environments, actually it's just a process or more but wrapped in its own environment.
So at first hand you could take any Docker image and the scripts inside would be there where the creators of the image placed them.
If you decide to create your own Docker images, and I believe you will sooner or later, then it is up to you how layout the system.
Additionally, you could link - proper term is here mount - your system's folders with those of the container but still the execution will take place inside the container.
For example to install the RStudio package in an Anaconda3 environment, I have tried the following.
As you can see, if installed as root user which is default, the path is
Additional note on the terms:
Now the concept of Docker is to create isolated virtual environments, actually it's just a process or more but wrapped in its own environment.
So at first hand you could take any Docker image and the scripts inside would be there where the creators of the image placed them.
If you decide to create your own Docker images, and I believe you will sooner or later, then it is up to you how layout the system.
Additionally, you could link - proper term is here mount - your system's folders with those of the container but still the execution will take place inside the container.
For example to install the RStudio package in an Anaconda3 environment, I have tried the following.
$ docker run -it continuumio/anaconda3 bash
(base) root@7162c3acc9e3:/# conda install -y -c r rstudio
(base) root@7162c3acc9e3:/# which rstudio
(base) root@7162c3acc9e3:/# /opt/conda/bin/rstudioAs you can see, if installed as root user which is default, the path is
/opt/conda/bin/rstudio. Most packages not using special system capabilities would considerably not "know" whether they are in a Docker environment or not, so in many cases you could consider a Docker container to be just a (fluid) environment you have the root access too.Additional note on the terms:
- image is a blueprint for a container defined by a Dockerfile. "Installing" something in an image means you add instructions to its Dockerfile. Own images can be derived from others by the statment FROM.
- container is basically process isolation in its own OS environment. If you install something in the container during its uptime, this change will be gone with the container.
Code Snippets
$ docker run -it continuumio/anaconda3 bash
(base) root@7162c3acc9e3:/# conda install -y -c r rstudio
(base) root@7162c3acc9e3:/# which rstudio
(base) root@7162c3acc9e3:/# /opt/conda/bin/rstudioContext
StackExchange DevOps Q#5713, answer score: 4
Revisions (0)
No revisions yet.