mysql docker connection error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’

I started docker mysql container and try to connect it outside docker using mysql command but got error:

It's because mysql clinet will use unix socket protocol as default protocol value to connect to mysql server if not specifying protocol or host argument, but mysql docker container is listening on tcp socket.


Specify IP address as host argument value in mysql command will make mysql to connect using TCP protocol instead of default unix socket.
(Note that using localhost as host argument value will still using unix socket protocol)

Or use

This command will specify protocol argument explicitly

Cannot install Docker on CentOS 6

Installing docker-ce on CentOS 6.9 got following error


To install docker on CentOS 6, run the following command


Then run

Its output is

Docker version 1.7.1, build 786b29d/1.7.1


We can see docker is installed successfully.

Docker SSH set password not working

First run passwd  command to change the password, after inputting new password, following output is shown.

passwd: password updated successfully

I bind docker port 22 to host port 33333, then running following command to connect to it using ssh with the new password we set earlier

After inputing password, following error is appeared

Permission denied, please try again.

SSH logs from /var/log/auth.log


To fix this issue, change /etc/ssh/sshd_config


Restart sshd and connect to it again, it should work now.