Docker Compose down. Can I run a command before the actual stop?

Viewed 349

I have a setup with docker-compose which creates a screen and runs a process in it.

That's because when I use the docker-compose with -d it will run the process in the background and attaching to the shell will actually give me a new shell.

What I need is the shell with the actual process...

So when I use my docker-compose script I use screen to run the process in a screen instance. When I open a shell I can connect to the shell of the running process using the screen -r <screen_name> command

But because it is running in a screen the docker-compose down command won't actually stop properly and will stuck while trying to stop. Instead, I need to force the stop and this is not what I want because this is not the proper way of ending the process I have.

So I thought I need a way to define a stop command before the actual stopping happens.

Any tips are appreciated.

PS: Yes, it's Minecraft

EDIT 1: After the comment of Calum Halpin I don't need a screen anymore. So that I now only need a way to pipe something like "exit" to stdin.

EDIT 2: I guess I still need screen. When attaching to the shell I cant escape from there without killing the terminal session and therefore the process...

0 Answers
Related