Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure environment variables on a Docker container without hard-coding them in the Dockerfile? [closed]

My dockerfile pulls a code repository from a private source which requires private credentials, and right now they are being hardcoded in the dockerfile as Environment variables. Is there a way to send them as either parameters like: docker run --name myContainer --env [email protected] --env PASS=password sgarcia/myimage

Is this possible?


edit: I'm an idiot, my pseudo code worked. I didn't think it was as simple as taht. Thanks Collin...

like image 942
sgarcia.dev Avatar asked Dec 17 '25 11:12

sgarcia.dev


1 Answers

Apparently the "pseudo-code" I came up to illustrate what I wanted actually worked for docker ...Thanks Collin

like image 66
sgarcia.dev Avatar answered Dec 20 '25 19:12

sgarcia.dev