Home > OS >  How to use list in "docker's run -e options"?
How to use list in "docker's run -e options"?

Time:11-12

I downloaded my spring boot project from git on Amazon Linux2 OS and made it a docker image.

Then, I tried to use the "docker run" command to run the docker container with this image.

At this time, there are values in the form of an array among the environmental variables I need, and other "docker run options" worked well, but there was a problem with the values in this form of an array.

// Command 1
docker run -itd --name example_container -e DDL_AUTO={update,create,validate} -p 80:8080 example_image

In command 1's case, docker: invalid reference format: repository name must be lowercase. error occured.

// Command 2 (put space between update, create, validate)
docker run -itd --name example_container -e DDL_AUTO={update, create, validate} -p 80:8080 example_image

In command 2's case, docker: invalid reference format. error occured.

Is there a way to put list optionally in this command format?

CodePudding user response:

You need to quote, try:

docker run -it -e DDL_AUTO="{update,create,validate}" --rm busybox ash -c 'echo $DDL_AUTO'

  • Related