I'm just learning Docker. If I want to use a particular image from Docker Hub, such as mysql, how do I know what environment variables can be used with that Docker image? Any way to get a list of the available variables?
If you look at any Dockerfile, search for lines that begin with ENV:
cat Dockerfile | grep ENV
If only an image is available, you can always do (--format=... is optional):
docker history --format="{{.CreatedBy}}" --no-trunc myimage | grep ENV
You can simply run it and see. This is what I got when I tried to run
docker run -it mysql
error: database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
Two ways to get the list of env variables:
You can checkout Dockerfile and look for ENV or docker run command and look for -e key value.
You can also check what actual env variables are populated in running container by following command -
docker exec -it <container id> env
This will give you a list of all populated env vars in that container.