- When you create the docker image you need to specify the port that will be accessible on the host system. To do this you need to specify the -p option to the run command. That means that it must directly follow run. For example 'docker run -p ...'
- You also need to specify which IP address the container should listen on and what host port should be mapped to the internal port of the container: '... 127.0.0.1:3306:3306 ...'
- This as a whole comes out as the following:
docker run -p 127.0.0.1:3306:3306 --name database-name-mysql -d mysql:5.5.43The database.yml file needs the host to be set to an IP, not 'localhost'.
development:
adapter: mysql
encoding: utf8
reconnect: false
pool: 55
host: 127.0.0.1 # NOTE: This can't be 'localhost' when you are running in Docker
port: 3306