简体   繁体   中英

Run Multiple Docker Images from One Bash script

I have a bash file that runs my apps docker image using docker run -it --network test_network -p 8000:8000 testApp but I also need to run my mysql image using docker run -it --network test_network -p 3308:3308 mysql/mysql-server

Normally I open a separate terminal window manually to run each one but I'm trying to edit my bash script so that it can do both for me. Not sure how though?

You can run both in the detached mode. That will not block the script and allow you to run both together. For that, you need to use the -d or --detach flag.

docker run --detach -it --network test_network -p 8000:8000 testApp

docker run --detach -it --network test_network -p 3308:3308 mysql/mysql-server

Edit: While the approach mentioned above works, it is better to use docker compose to run multiple containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM