R
Railwayβ€’9mo ago
Afo

Start command for docker image

Is there any way to provide launch command for the container? Command which I'm talking about looks like this: `docker run -e TOKEN=$TOKEN -e KEY=$KEY app_name_here' Error "Invalid command" is given when I'm trying to put it as a start command. Whole case looks like this: GitHub ----- GH Actions Building and Pushing Docker Image -----> Docker Hub ---- Pulling From DockerHub to Railway -----> Run Image with above command Docker Image is not equipped with env variables due to public nature of this repo... that's why I'm doing it like that. Of course this image is working as planned on my local machine.. so is there any way to solve that? Or maybe any other way to handle it?
Solution:
Service variables are scoped to that isolated deploy
Jump to solution
17 Replies
Percy
Percyβ€’9mo ago
Project ID: N/A
Afo
Afoβ€’9mo ago
N/A Of course direct deploy from repo is also working fine, but I wanted to get it done this way.
Floris
Florisβ€’9mo ago
Railway has a system variables feature scoped to your container deploy @Afo You go to your deploy > Variables > + New Variable Add your vars as you wish, when you launch your docker it should populate the placeholders in your docker with the railway vars
Floris
Florisβ€’9mo ago
No description
Floris
Florisβ€’9mo ago
Afo
Afoβ€’9mo ago
What's the difference between service vars and shared variables? They are not behaving in same way?
Afo
Afoβ€’9mo ago
Talking about this:
No description
Afo
Afoβ€’9mo ago
So are you saying that service variables are going to get injected into container?
Solution
Floris
Florisβ€’9mo ago
Service variables are scoped to that isolated deploy
Floris
Florisβ€’9mo ago
Yes Thats correct And shared variables, lets say you have 3 containers accessing 1 api You can declare 1 shared variable and call the shared variable in all 3 containers while only declaring it once as a shared var But for your application, system would be fine Make sure you tell railway where the variables need to be populated however with the correct placeholder in your code
Afo
Afoβ€’9mo ago
Okay, so just one more question because I'm not sure about that.. so basically let's say with Python I'll be able to call that vars in my code like os.environ["VAR_NAME"] is that correct? Or do I need to make some extra work?
Floris
Florisβ€’9mo ago
yes correct! however i would resort to using the
.get
.get
attribute on your
os.environ
os.environ
so it would be
os.environ.get["VAR_NAME"]
os.environ.get["VAR_NAME"]
when you use the .get it will return None when you have the wrong name if you call the normal dict it will raise an error try this and tell me if it works
Afo
Afoβ€’9mo ago
Ah yea sure, got it Thank you, I'll try that Appreciate your help πŸ™‚
Floris
Florisβ€’9mo ago
from there u can error handle however u want when the value is None yessir no problem
Afo
Afoβ€’9mo ago
Oh yea.. now everything works fine with image from docker hub, once again thanks @Morpheus 😁
Floris
Florisβ€’9mo ago
cool bro! @Brody can you mark this as solved? or maybe you can @Afo
Afo
Afoβ€’9mo ago
Done