Running and connecting to different MySQL servers in Docker containers

Running and exposing default MySQL port: docker run -e MYSQL_ROOT_PASSWORD=mypassword -p 3306:3306 -d mysql mysql -u root -p Running with a different exposed port on the host: docker run -e MYSQL_ROOT_PASSWORD=mypassword -p 3307:3306 -d mysql Connecting to server on different port : -P option, but also requires -h for host, otherwise seems to connect to …