How do I run a command in a deployed container?
dvf
PROOP

10 months ago

I'm using a Dockerfile as my deployment method.

Usually platforms (Heroku, Fly, Render, etc) allow you to run something like railway console which spins up a container in the same environment to allow you to run short-lived tasks like data migrations.

I tried using railway ssh after linking to the correct service and I receive:

  proj git:(master)  railway ssh         
Expected welcome message, received: ServerMessage { type: "error", payload: ServerPayload { data: Empty, message: "No deployment found to connect to", code: None } }

Any help would be greatly appreciated.

7 Replies

dvf
PROOP

10 months ago

1a10151c-e218-451e-9211-fc31ae984e88


10 months ago

Do you wanna do data migrations or do you just used it as an example?


10 months ago

Data migrations should be done in a pre-deploy command



10 months ago

Also, to be able to use SSH in a service there's some caveats, the built image must include a shell bash and it must be currently running


dvf
PROOP

10 months ago

I think that's contextual. Sometimes migrations are better run as a post-deploy step (for example, if they depend on some state of the application).

In any case, we have a data migration that needs to be run as a once-off. Is SSH the only way?


10 months ago

SSH or railway run to ran locally but using railway environment variables


Loading...