I am adding many things to the .bashrc in the Dockerfile which is necessary to execute some of the commands I want to run later in the Dockerfile,
I tired source .bashrc
which does not work.
I tried using RUN /bin/bash -c --login ...
but I get an error : mesg: ttyname failed: inappropriate ioctl for device
In most cases, the bashrc is a hidden file that lives in your home directory, its path is ~/. bashrc or {USER}/. bashrc with {USER} being the login currently in use.
Source to update your current shell environment (. bashrc is a script file executed whenever you launch an interactive shell instance. It is defined on a per-user basis and it is located in your home directory.
Each command in a Dockerfile creates a new temporary container, but without tty (issue 1870, discussed in PR 4955, but closed in favor of PR 4882).
The lack of tty during docker builds triggers the ttyname failed: inappropriate ioctl for device
error message.
What you can try instead is running a wrapper script which in it will source the .bashrc
.
Dockerfile
:
COPY myscript /path/to/myscript
RUN /path/to/myscript
myscript
:
#!/bin/bash
source /path/to/.bashrc
# rest of the commands
Abderrahim points out in the comments:
In my case it was for
nvm
: it adds aninit
script to.bashrc
therefore it wasn't usable in the Dockerfile context.
Ended up making an install script with it's dependent command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With