/start.sh
script at the end of the container startup process.
You can customize the Docker command to run additional commands or modify the default behavior.
For example, you can add a command to run before /start.sh
:
/testdir1
before running /start.sh
.
Using the entrypoint
Field
You can also specify a JSON string with cmd
and entrypoint
as the keys.
The entrypoint
field allows you to specify a command to run at the beginning of the container startup process. For example:
echo
command and then runs /start.sh
.
Important Considerations
When using the entrypoint
field, be aware that the command will run twice: once as the entrypoint and again as part of the cmd
field.
This can cause issues if the command errors when run a second time. For example:
mkdir
twice, which can cause errors if the directory already exists.
Tips and Examples
Here are some working examples to try in dev:
bash -c 'mkdir /testdir1 && /start.sh'
{"cmd": ["bash", "-c", "mkdir /testdir8 && /start.sh"]}
{"cmd": ["test-echo-test-echo"], "entrypoint": ["echo"]}
{"cmd": ["mkdir -p /testdir12 && /start.sh"], "entrypoint": ["bash", "-c"]}
mkdir -p
to avoid errors when creating directories.