How to build non-web python application image with buildpack? How to build non-web python application image with buildpack? docker docker

How to build non-web python application image with buildpack?


When you start the container, you'll need to pass it the worker process type like this:

$ docker run -it myapp worker

Then it should run the the command you added to the Procfile.

A few other things:

  • Make sure you're using the heroku/python buildpack or another buildpack that includes Procfile detection.
  • Confirm in the build output that the worker process type was created
  • You can put your command as the web: process type if you do not want to add worker to your start command. There's nothing wrong with a web: process that does run web app


Thank @codefinger for reminder. with several trials, I finally get my application launched with below command:

    docker run -it --name container_name image_name python mycode.py

In fact docker run command has its format as:

docker run [options] image [command] [arg..]

I suspect even buildpack image has no worker process, it is still possible to use "command" option to launch your application.

However, successfully running image built by buildpack without any error leaves me an increasing weird feeling.
Same code and same requirement.txt file, nothing changed! Why image built by docker build gives me a TypeError? So weird.