I want to create and start a docker container with some arguments (to the CMD) through docker API using a json file.
curl -XPOST --unix-socket /var/run/docker.sock -d @minio.json -H 'Content-Type: application/json' http://localhost/containers/create?name=minio
curl -XPOST --unix-socket /var/run/docker.sock -H 'Content-Type: application/json' http://localhost/containers/minio/start
I tried to put them in the top of the json and the HostConfig "sub entry"
"Args": "server --address 192.168.150.3:80 /export",
but when I inspect the arguments are not there.
In the documentation there are examples only when you inspect a container and see the arguments.
Is there a way to pass Args within the json file or when you start the container with curl and a payload ("docker run" is excluded) ?
Solution is to list all arguments in double quotes in the array.
"Cmd": [
"server" ,"--address", "192.168.100.8:8888", "/export"
],
The API has two attributes in JSON
"Cmd": [
"date"
],
"Entrypoint": "",
You need to change the Cmd
array to pass the arguments you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With