Ali
Ali

Reputation: 267077

Setting $PATH in docker image?

I'm creating a base image for my projects. In this base image, I will download a few .tar.gzs and extract them.

I want to add these unzipped directories to be added to the path, so in child images, I can call up the downloaded executables directly without needing to specify the full path.

I tried running export PATH... in the base image, but that doesn't seem to work (at least when i tty into it, i don't see the path updated, I assume because the export doesn't transfer over into the new bash session).

Any other way to do this? Should I edit the .bashrc?

Upvotes: 1

Views: 1634

Answers (2)

Hiren
Hiren

Reputation: 130

Currently the way you are setting $PATH will not cause the modification to be persistent across sessions. Please see the Bash manual on startup files to see which files you can edit to set the environment permanently,

Upvotes: 0

Mike Tung
Mike Tung

Reputation: 4821

If you are trying to set some environment variables you can use the -e option to set environment variables. for example suppose you can do

docker run -e PASSWORD=Cookies -it <image name> bash

which when run you can check to see if $PASSWORD exists with an echo $PASSWORD

Upvotes: 1

Related Questions