Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to run source command from Dockerfile

This is the script in Dockerfile. When I directly get into the docker and run the commands manually it is working fine but why not from the Dockerfile.

Dockerfile:

FROM ubuntu:16.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update
RUN apt-get install -y build-essential libssl-dev
RUN apt-get install -y curl git sudo

RUN curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh
RUN /bin/sh install_nvm.sh
RUN source ~/.profile

Error:

mesg: ttyname failed: Inappropriate ioctl for device

I have tried few of the solutions found like running it as RUN /bin/sh -c "source ~/.profile" and few more but not solving the issue.

like image 452
Tara Prasad Gurung Avatar asked Nov 17 '22 04:11

Tara Prasad Gurung


1 Answers

This is very similar to this question: How to solve 'ttyname failed: Inappropriate ioctl for device' in Vagrant?

In ~/.profile there is a line:

mesg n || true

That is incompatible. In order to fix it, make it conditional upon if tty is available (credit Gogowitsch):

RUN sed -i ~/.profile -e 's/mesg n || true/tty -s \&\& mesg n/g'

This sed command replaces mesg n || true (try it, and ignore if it fails) with tty -s && mesg n, (only try it if it will succeed) which makes the error message go away

like image 153
Jonathan Gawrych Avatar answered Nov 19 '22 23:11

Jonathan Gawrych