RUN source command not found

5,701 views
Skip to first unread message

Fernandez

unread,
Jun 27, 2014, 1:14:44 PM6/27/14
to docke...@googlegroups.com
Hi all,

I need to use the command source but I get that the following error:

RUN source /etc/project/bin/activate

source: not found

ENTRYPOINT python /etc/project/src/start.py

However, if I enter in the container and run it everything works fine.

What can I do ?

Thanks,

Best,
Fernandez

James Mills

unread,
Jun 27, 2014, 6:05:13 PM6/27/14
to Fernandez, docker-dev
Hi,

``source`` is not a command. It's a Bash (or shell) function.

Normally it's run inside a Bash shell.

e.g:

source /path/to/bash_script

I'm not entirely sure you can affect the "shell environment"
of the Docker buidl in this way. Not sure...

cheers
James

--
You received this message because you are subscribed to the Google Groups "docker-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to docker-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Frederick Kautz

unread,
Jun 27, 2014, 11:40:31 PM6/27/14
to docke...@googlegroups.com, hector.2...@gmail.com
This is correct, I recommend creating a script that runs as the entry point.

#!/bin/sh
source /my/project/bin/activate
/my/project/bin/execute

Graham Bell

unread,
Jun 28, 2014, 5:08:49 AM6/28/14
to docke...@googlegroups.com
If your using source to read a file that contains environment variables, you could also use ENV in your Dockerfile to set them ..
Just a thought..

Graham

Jérôme Petazzoni

unread,
Jun 29, 2014, 8:07:27 PM6/29/14
to Graham Bell, docker-user
Hi Fernandez,

(Switching that thread to docker-user since it's probably more appropriate there...)

In that specific case (running a Python program using virtualenv), the easiest solution is to reference the full path to the Python interpreter in the virtualenv.

In other words:

ENTRYPOINT /etc/project/bin/python /etc/project/src/start.py

HTH,



--
You received this message because you are subscribed to the Google Groups "docker-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to docker-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fernandez

unread,
Jun 30, 2014, 11:54:07 AM6/30/14
to docke...@googlegroups.com, hector.2...@gmail.com
Thanks Frederic,

I finally decided to define an ENTRYPOINT passing as command the instructions with the absolute path of my virtualenv.

RUN chmod -R 750 /etc/project
ENTRYPOINT /etc/project/bin/activate && /etc/project/bin/python /etc/project/src/start.py

However, I also tried your version but I got a permission denied error. I didn't dig into it but I imagine that adding "RUN chmod ..." prior my script will make it to work.
 
Fernandez
Reply all
Reply to author
Forward
0 new messages