cancel
Showing results for 
Search instead for 
Did you mean: 
ChrisGR
Flight Engineer
Flight Engineer
  • 4,961 Views

Podman search - Environmental variables

Hello all,

Let's say that we want to create a container that needs be fed with environmental variables when started (such as mysql). How we are going to know beforehand the environment variables using ONLY the CLI?

podman inspect or skopeo inspect do not provide detailed info on the env. vars that are available for a specific image.

Regards,

Chris

Labels (3)
5 Replies
EmanuelHaine
Flight Engineer
Flight Engineer
  • 4,891 Views

Hello,

I think it might help you.

With skopeo inspect, you can search for the keywork "usage":

skopeo inspect <URL> | grep usage

Screenshot from 2022-02-23 22-01-41.png

I hope it help you!

ChrisGR
Flight Engineer
Flight Engineer
  • 4,855 Views

Hello Emanuel,

Thanks a lot! But it seems that usage states only an example, and not the whole list of the environmental variables supported by the image.

Regards,

Chris

Tracy_Baker
Starfighter Starfighter
Starfighter
  • 4,794 Views

@ChrisGR 

If you do a podman run and don't specify environment variables, you might get what you want. This method may not work for everthing. For mariadb, it returns this:

1.JPG

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
MarkosS
Flight Engineer
Flight Engineer
  • 4,271 Views

I do try the previous answers but sometimes no info is visible in skopeo or when starting the container.

As a workaround I also try openshift: If a template is available it can provide the list of env parameters oc new-app (oc process templatename --parameters). Of course this works only if there is an available template... 
I haven't found a generic solution to to this 

Chetan_Tiwary_
Community Manager
Community Manager
  • 3,042 Views

Hello @ChrisGR ,

A very good question !

The docker inspect command lets you see the environment variables for a Docker image.

An example command to display the MySQL Docker environment variables:

 


docker inspect --format='{{json .Config.Env}}' mysql:latest | python -m json.tool

 

Using the "json.tool" Python module, this command will output the environment variables in JSON format.

 

Replace mysql:latest with the name and tag of the Docker image you want to inspect.

 

Some Docker images don't define environment variables, and even if they do, they may not be necessary for the container to work.

Usually the Docker image or application documentation will tell you what environment variables are required and how to set them.

Join the discussion
You must log in to join this conversation.