I want to use plenv to have perl 5.16 in the docker image. apt-get only get 5.14.
plenv will install perl in $HOME/.plenv/versions/5.16.2/, and I need to append some lines into $HOME/.profile:
export PATH="$HOME/.plenv/bin:$PATH"
eval "$(plenv init -)"
Then run plenv shell 5.16.2 to swith to the new version.
But in Dockerfile, I need to write source $HOME/.profile && plenv shell 5.16.2 everyline before I run some perl commands. docker didn't exec $HOME/.profile, is it a no-login shell?
Though I could write such command before every RUN, how can I do this in CMD line?
Do docker can solve this by some setting?
You can use the ENTRYPOINT command to prepend something before each executions or you can simply move your .profile within your .bashrc.
Indeed, docker is a no-login shell, it will not run upstart, simply execute the requested process.
Related
When using kubectl run -ti with an interactive terminal, I would like to be able to pass a few commands in the kubectl run command to be run before the interactive terminal comes up, commands like apt install zip for example. In this way, I do not need to wait for the interactive terminal to come up and then run those common commands. Is there a way do so this?
Thanks
You can use the shell's exec to hand control over from your initial "outer" bash, responsible for doing the initialization steps you want, over to a fresh one (fresh in the sense that it does not have -c and can optionally be a login shell) which runs after your pre-steps:
kubectl run sample -it --image=ubuntu:20.04 -- \
bash -c "apt update; apt install -y zip; exec bash -il"
What I've tried:
bash scripts/shell/test.sh
sh scripts/shell/test.sh
These were the results:
The term 'bash' is not recognized...
The term 'sh' is not recognized...
This may sound daft, but if you are in a Powershell shell how will that shell know where to find the bash or sh interpreter? Is it already defined in the environment?
In my opinion you're going to have to tell the Powershell terminal where it should find the bash/sh interpreter, i.e. call bash it with the full pathname
i read you're suppose to use chmod +x scriptname.sh before using the bash command
I have a strange error with linux somehow interpreting sudo -H as two separate commands.
I'm on Cent OS 7, and I get the following:
/var/tmp/<random string>: line 8: -H: command not found
This is very vexing to me. Why would it not know this uption of sudo?
My guess would be that you have an alias or bash function that is suppressing your call to sudo. Try running the command with the full pathname for sudo (/usr/bin/sudo) on both systems, and type type sudo to see if there is an alias or bash function that is being called instead of the executable.
If there is, check the usual places like ~/.bashrc for where it is being defined so you can remove it.
Alternatively, it could be unrelated to sudo, and instead be related to whatever script you are calling with sudo.
I love the terminal feature and works very well for our use case where I would like students to do some work directly from a terminal so they experience that environment. The shell that launches automatically is sh and does not pick up all of my bash defaults. I can type "bash" and everything works perfectly. How can I make "bash" the default?
Jupyter uses the environment variable $SHELL to decide which shell to launch. If you are running jupyter using init then this will be set to dash on Ubuntu systems. My solution is to export SHELL=/bin/bash in the script that launches jupyter.
I have tried the ultimate way of switching system-wide SHELL environment variable by adding the following line to the file /etc/environment:
SHELL=/bin/bash
This works on Ubuntu environment. Every now and then, the SHELL variable always points to /bin/bash instead of /bin/sh in Terminal after a reboot.
Also, setting up CRON job to launch jupyter notebook at system startup triggered the same issue on jupyter notebook's Terminal.
It turns out that I need to include variable setting and sourcing statements for Bash init file like ~/.bashrc in CRON job statement as follows via the command $ crontab -e :
#reboot source /home/USERNAME/.bashrc && \
export SHELL=/bin/bash && \
/SOMEWHERE/jupyter notebook --port=8888
In this way, I can log in the Ubuntu server via a remote web browser (http://server-ip-address:8888/) with opening jupyter notebook's Terminal default to Bash as same as local environment.
You can add this to your jupyter_notebook_config.py
c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
With Jupyter running on Ubuntu 15.10, the Jupyter shell will default into /bin/sh which is a symlink to /bin/dash.
rm /bin/sh
ln -s /bin/bash /bin/sh
That fix got Jupyter terminal booting into bash for me.
I'm running into an issue installing a package that's reliant on ocamlfind but I'm getting an ocamlfind: command not found error when making.
I have installed ocamlfind with the ocaml package manager and have tried reinstalling using "opam reinstall ocamlfind".
I have also tried the 'eval opam config env' command to see if updates my bin.
Has anyone run into a similar issue/know what this might be caused by
The output when running the make:
make
ocamlfind ocamlc -pp "camlp4o -I lib/dcg -I lib/ipp pa_dcg.cmo pa_ipp.cmo" -w usy -thread -I lib -I lib/dcg -I lib/ipp -c semantics.ml
/bin/sh: ocamlfind: command not found
The output when trying ocamlfind
ocamlfind
-bash: ocamlfind: command not found
ocaml is installed
opam install ocamlfind
[NOTE] Package ocamlfind is already installed (current version is 1.5.5).
and when running the eval command
eval 'opam config env'
CAML_LD_LIBRARY_PATH="/home/centos/.opam/system/lib/stublibs:/usr/lib64/ocaml/stub libs"; export CAML_LD_LIBRARY_PATH;
MANPATH="/home/centos/.opam/system/man:"; export MANPATH;
PERL5LIB="/home/centos/.opam/system/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/home/centos/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
PATH="/home/centos/.opam/system/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin"; export PATH;
I'm on a server running centos 7
This command
eval 'opam config env'
is almost assuredly a typo and was supposed to be
eval `opam config env`
though using $(...) instead is the modern equivalent and avoids this font-fact confusion
eval $(opam config env)
That being said that just sets the environment variables in the current shell session (and exports them for use by processes run by this shell session).
As such that needs to be run in every shell session that needs those set (including each line of the makefile that expects them to be set if the environment that runs make doesn't already have them set and exported).
try
sudo apt-get install ocaml-findlib