• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Starting services/commands/scripts at startup of a container
#1
Hello,

how can I start services or commands at the startup of the container. I tried the command field in advanced options, but then the container doesn't start right.

Thanks in advance,

Jonas
  Reply
#2
What commands exactly to you mean? Portainer.io in the used version 1.12.4 on netPI does not offer you all docker commands.

The command field in portainer is this one "docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]"

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#3
I tried to start a python script at the startup of the container. For that I put it in the rc.local but after every startup the script hasn't been executed. Then I tried to start it with the command field, but I don't know if it's possible to specify it there.

Thanks
Jonas
  Reply
#4
Hello Jonas,

you have to dig into the details of Docker technology to understand that rc.local and similar things do not work in a container. You have to take care of all such automatic start commands yourself.

Even if you specify a command like you tried the container will start the ENTRYPOINT command that has been specified by us when we have created the container image. All our example containers are starting the file entrypoint.sh that is in the /etc/init.d folder.

There are two methods to start you own commands:

1.) You make you own private container and do not use you example any more and make changes in the entrypoint.sh file in accordance to your ideas or use any other file when the container image is built.

2.) You use the existing container and specify a different Entry Point file in the web browser GUI when you Add a Container. Then this file is used instead of our default file entrypoint.sh.

Thx
Armin

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#5
Hello Armin,

I fixed it by starting the python script inside the entrypoint.sh.
Thank you for your help.
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Ready-to-deploy: full featured Node-RED container Armin@netPI 3 48 Yesterday, 02:45 PM
Last Post: AlexRegev
  New Container example "OPC UA server" Armin@netPI 0 13 April-12th-2019, 11:51 AM
Last Post: Armin@netPI
  Official Node-RED container Armin@netPI 0 15 April-5th-2019, 10:39 AM
Last Post: Armin@netPI
  Multi-stage builds for slim container images Armin@netPI 0 10 February-7th-2019, 04:14 PM
Last Post: Armin@netPI
Information [INFO] Setting the correct timezone in a container Armin@netPI 0 10 February-3rd-2019, 08:23 AM
Last Post: Armin@netPI
  [SOLVED] Unique identifier in container mmolder 1 25 January-23rd-2019, 03:06 PM
Last Post: Armin@netPI
  [SOLVED] activate LED1/2 with Node-RED + fieldbus nodes container Christian_Rau 5 75 January-11th-2019, 08:06 AM
Last Post: Armin@netPI
  [SOLVED] install ssh service to running container paubau 2 135 October-12th-2018, 01:03 PM
Last Post: paubau
  [SOLVED] nodered : flows_localhost deleted after creating an image from container paubau 6 186 September-21st-2018, 10:19 AM
Last Post: paubau
  [SOLVED] MySQL Container / Server in another Container? paubau 2 152 September-5th-2018, 08:00 AM
Last Post: paubau

Forum Jump:


Users browsing this thread: 1 Guest(s)