Today’s question is concerning automatic container start up on docker-copose file,
I wanted to have certain docker container that can manually be start up,
My goal is too have 3 “core” docker containers that always startup at the first boot of my system through docker-compose and then selecting manually whcich docker container I can start or not.
First of all I was thinking of building my own custom images with all the images I want to have on my system and providing my docker-compose file with only the three of my “core” containers. But this doesn’t work because I think that when I create my “bundle” directory it looks at which container is reference in my docker-compose file and ignores all the rest.
So I asked myself : "What about prooviding my docker-compose file with all my containers images I want to have, and then manage (somehow) to avoid automatic startup for certain containers so I can manually choose which one I start ".
The question is HOW TO DO THAT ? Is there a docker-compose command ? I tried “restart=no” but this doesnt affect the fisrt boot of my toradex verdin-imxm8p.
Thank you in advance for your help,
I hope I was clear enough, if not don’t hesitate to ask for more details,
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello Muzzy,
Thank you for reaching out with your question about managing Docker containers on your Toradex system. To achieve your goal of having certain containers start automatically while others remain manual, you can configure your Docker Compose file effectively. Here’s how you can set this up on Torizon OS:
Docker Compose File Location: Make sure your docker-compose.yml file is located in the /var/sota/storage/docker-compose/ directory on your Torizon system. This is the directory Torizon OS uses to identify containers that should start at boot.
Configuring Automatic Start: For the containers you want to start automatically, use the restart policy in your docker-compose.yml file. Set it to always or unless-stopped for these containers. This ensures they start at boot and restart if they fail.
Preventing Automatic Start: For containers you want to start manually, omit the restart policy or set it to no. This will prevent them from starting automatically at boot.
Example:
services:
manual_service_1:
image: your-manual-image-1
restart: no
manual_service_2:
image: your-manual-image-2
restart: no
Manual Start: To start these containers manually, use the Docker Compose command:
docker-compose -f /var/sota/storage/docker-compose/docker-compose.yml up manual_service_1
Replace manual_service_1 with the name of the service you wish to start.
By configuring your docker-compose.yml file in this way, you can control which containers start automatically and which require manual intervention. This setup allows you to maintain flexibility in managing your containerized applications on Torizon OS.
I hope this helps! If you have any more questions, feel free to ask.
Best regards,
Toradex AI Assistant
Please, also check if these links can help you solve your problem:
The comments from @ToradexAI go in the right direction, however adding the following combination or configurations to a service has proven to prevent auto-start in the past:
services:
service_name:
...
restart: never
profiles:
- donotstart
Please let me know if either of these suggestions work.
I tried your suggestion, this is working but the container are not even created ?
When I run a docker container start “nameofmycontainer” it’s saying there is not such a container.