I built a MySQL container from an image, found its IP address but unable to connect from command line or mysqlworkbench. Here's my configuration.
Dockerfile
FROM mysql
ENV MYSQL_DATABASE=test
ENV MYSQL_ROOT_PASSWORD=password
COPY ./schema.sql /docker-entrypoint-initdb.d/
Command
docker build -t mysql-image .
&& docker run
-p 6603:3306
--name mysql-container
mysql-image
I can see that the container is running from docker container ls
. I found its IP address using this command with the help of this answer.
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-container
It gave me this ip -> 172.17.0.2
Error
Edit
The linked duplicate tag isn't the solution, the problem lies with the following command that misled me.
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-container