Question

App Platform deploy Docker container with custom `docker run ...` args

Hello, I am trying to deploy a docker container using App Platform. In order for my container to work correctly I need to specify a custom CLI docker run command. For Example, docker run -e myEnvVar=MyVal --restart always However I have been unable to get this to work successfully.

These docs here seem to indicate I may need to modify my “build commands” however I see no option to create / modify my build commands.

I resorted to modifying my app specs (see same link for information) however this also did not fix my issue.

Additional Specifications:

  • Container Registry: Docker hub

If I don’t specify any “build commands”, the container runs but crashes in the same way it does on my local machine when I don’t specify any docker run commands.

tl;dr: How to implement custom docker run ... commands when deploying a docker container using App Platform.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 24, 2024

Hey!

You should not need the --restart always flag as the App Platform takes care of this for you, e.g. if the container stops the App Platform will know and make sure that it is running.

For the -e this is also already handled for you, all that you need to do is to specify your environment variables in your app and the App Platform will handle the passing of those env variables in the run command:

https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/

If you are using a Docker registry, there will be no build command as your images are going to be essentially already built and available on the registry.

The build command will be available when deploying using a Dockerfile or the native buildpacks, but if you already have an image available you don’t need it.

Let me know how it goes once you’ve defined your environment variables in the App Platform.

If it is still failing, feel free to share the exact error that you are seeing.

  • Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console