0

I just write a customized container dockerfile including CMD["uwsgi", "--ini", "uwsgi.ini"] based on nginx official image

And I see there's a CMD["nginx", "-g", "daemon off"] in the end of Dockerfile of this nginx official image.

That should means starting nginx when container starts. So my CMD["uwsgi", "--ini", "uwsgi.ini"] in my dockerfile will overridde it, thus the container will immediately exit. How should I not override it and make both nginx and uwsgi work?

I'v googled a lot but none of those solutions are based on nginx official image. Obviously I can run another container just for uwsgi and connect it to nginx container(i.e. the container runned by nginx offcial image), but I think it's troublesome and unnecessary.

the nginx offcial image here

2 Answers2

0

You can use ENTRYPOINT or CMD to run multiple processes inside a container by feeding a shell script/wrapper. You should try to refrain from it since that isn't a best practice. Single container should be responsible for managing single process.

However there is a workaround by which you can manage multiple processes inside a container i.e by using a shell script wrapper or supervisor.
It's there in official docs -
https://docs.docker.com/config/containers/multi-service_container/

vivekyad4v
  • 13,321
  • 4
  • 55
  • 63
0

First, this is not docker philosophy to run 2 processes in one container. This is a commonly accepted one : officialy, and through the community

So you'd rather build a stack, with both a nginx and your application.

Provided you really want or need to do this your way, you can pipe several command within the CMD instruction if you specify the command shell at first... but you can also use a script here.
Remember that the script will be executed from within your container, so think from a container POV, and not from a host one!

Marvin
  • 1,650
  • 4
  • 19
  • 41