InternationalCodingGuru
InternationalCodingGuru

Reputation: 2258

re-run Python script in started in docker-compose with MySQL server running

Using docker compose I've created a container for my MySQL DB and one for my Python script. When I use the command docker compose up, my images are built for my Python app container and my MySQL DB container, and the python script is run. After execution, the shell just hangs since MySQL server is still running and my script has completed execution. How can I either stop the MySQL server after my script runs, or re-run my script while the MySQL server continues to run?

Upvotes: 0

Views: 216

Answers (1)

Nguyen Lam Phuc
Nguyen Lam Phuc

Reputation: 1431

When running docker-compose up, your current shell will display all the logs from all the containers defined in the docker-compose.yaml file. Also if you terminate the command with cmd + c in MacOS, all the containers will stop running.

As a result, this gives you the impression that the shell just hangs while everything is still running as normal.

What you want in this case is to let the containers continue to run in the background (detached mode)

docker-compose up --detach

The MySQL server will now continue to run until you stop it with docker-compose down.

Upvotes: 1

Related Questions