Tuesday, September 11, 2018

To pass environment variable to container

To pass any env. variable to container.

--env or -e switch and pass the key-value pairs right to it.


docker container run -d -p 3306:3306 --name db -e MYSQL_RANDOM_PASSWORD=yes mysql

To check the log output.:

docker container logs db

In the log, you can see the output "GENERATE ROOT PASSWORD: <something>"
If not found, run again the same logs command to refresh the logs.




docker container stop db<one or more container IDs>


No comments:

Post a Comment