Reputation: 18124
New to Docker and I'm reading that a Dockerfile can only have 1 CMD.
So how do I start both my database server and application server? Something like:
CMD /root/database/bin/server run &
CMD /root/appserver/bin/server run &
Upvotes: 0
Views: 127
Reputation: 31605
Docker can run as many processes as you want to. It is no problem to run a database and an application server in the same container. However, you can only run one command in your container, so this command must start all other processes and it must run as long as your container runs (if it stops, your container will stop).
So start a shell script which itself will start all other things:
CMD /run.sh
The shell script could look like this:
echo "Lets start up"
:: Run your database server in background
/root/database/bin/server run &
:: Run your app server (not in background to keep the container up)
/root/appserver/bin/server run
Upvotes: 1
Reputation: 35139
Docker can only start one process in a container - but that process can start whatever it likes.
Supervisord has been a popular choice to use that will then go on to star whatever else you want/need to.
Upvotes: 4