Docker Community Forums

Share and learn in the Docker community.

Now able to fetch variable by using find command in docker

docker exec -it wordpress env | find /i “mysql” FIND: Parameter format not correct
When i tried to fetch data of mysql from env, iam getting FIND parament is not correct

================================================================
application is to create a database server:

docker rm -f (docker ps -qa)
$ docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=wordpress -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=password mariadb
221462288bc578511154fe79411de002e05f08642b63a72bc7a8f16f7102e52b

The next step is to run a WordPress container. In that command, we will link the wordpress container with the mariadb container:

$ docker run -d --name wordpress --link mariadb:mysql -p 8080:80 wordpress
Unable to find image ‘wordpress:latest’ locally
Trying to pull repository docker.io/library/wordpress
latest: Pulling from docker.io/library/wordpress

output truncated for brevity

Digest: sha256:670e4156377063df1a02f036354c52722de0348d46222ba30ef6a925c24cd46a
1f69aec1cb88d273de499ca7ab1f52131a87103d865e4d64a7cf5ab7b430983a

Let’s check container environments with the docker exec command:

$ docker exec -it wordpress env|grep -i mysql
MYSQL_PORT=tcp://172.17.0.2:3306
MYSQL_PORT_3306_TCP=tcp://172.17.0.2:3306
MYSQL_PORT_3306_TCP_ADDR=172.17.0.2
MYSQL_PORT_3306_TCP_PORT=3306
MYSQL_PORT_3306_TCP_PROTO=tcp

output truncated for brevity

Finally, if your issue has not been addressed elsewhere, running:

  • :whale: :arrow_right: Settings :arrow_right: Diagnose & Feedback :arrow_right: Open Issues.

This forum is not an official product support or issue reporting channel.

It would be nice, if you change the post title from Now able to fetch variable by using find command in docker" to something more fitting… The find command is used to find files and folders, but not actualy find text in a output stream. Get all set environment and grepping it’s output in case insensitive is the right aproach.

Usualy I would say: never, ever use container ip’s directly. Though, it seems theses have been created from the mariadb container and thus hopefully, as a container ip will eventualy change, always points to the current container ip.