Reputation: 51
What is the difference in below three declarations for passing command/arguments:
containers:
name: busybox
image: busybox
args:
-sleep
-"1000"
containers:
name: busybox
image: busybox
command: ["/bin/sh", "-c", "sleep 1000"]
containers:
name: busybox
image: busybox
args:
-sleep
-"1000"
A. Would these produce same result?
B. What is the preference or usage for each?
Upvotes: 0
Views: 311
Reputation: 852
The YAML list definition are only a matter of taste, it's just a YAML syntax. This two examples are equivalent:
listOne:
- item1
- item2
listTwo: ['item1', 'item2']
And this syntax works for both args and command. Beside that args and command are slight different, as the documentation says:
Imagine a container like mysql, if you look it's Dockerfile you'll notice this:
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["mysqld"]
The entrypoint call a script that prepare everything the database needs, when finish, this script calls exec "$@"
and the shell variable $@
are everything defined in cmd.
So, on Kubernetes, if you want to pass arguments to mysqld you do something like:
image: mysql
args:
- mysqld
- --skip-grant-tables
# or args: ["mysqld", "--skip-grant-tables"]
This still executes the entrypoint but now, the value of $@
is mysqld --skip-grant-tables
.
Upvotes: 1