You should run the application as a foreground process. Do not use a "service" script or anything else that launches the application as a daemon.
# Run the application itself, not a "start" script that launches
# a background process
command: /home/admin/admin_application
Typically this main command is a property of the image: whenever you start the container this is the thing you'll almost always want to run. That means it's more appropriate to specify this as the CMD
in your Dockerfile:
CMD ["/home/admin/admin_application"]
Then in your docker-compose.yml
you don't need to override this value. You also shouldn't usually need to specify container_name:
(Compose can assign this on its own), tty:
(only needed for interactive programs), or network_mode: host
(which generally disables Docker networking). Your docker-compose.yml
can be as little as
version: "3.9" # "3" means "3.0"
services:
xx:
image: xx:1.0
# ports: ["8080:8080"]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…