Skip to content

Commit 1aa826b

Browse files
committed
Updated README
Added notes about port forwarding and passing in server options
1 parent c22ce30 commit 1aa826b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ Note that users on systems with SELinux enabled may experience problems with thi
137137

138138
If you start your MySQL container instance with a data directory that already contains a database (specifically, a `mysql` subdirectory), the `$MYSQL_ROOT_PASSWORD` variable should be omitted from the `docker run` command line; it will in any case be ignored, and the pre-existing database will not be changed in any way.
139139

140+
## Port forwarding
141+
142+
Docker allows mapping of ports on the container to ports on the host system by using the -p option. If you start the container as follows, you can connect to the database by connecting your client to a port on the host machine, in this example port 6603:
143+
144+
docker run --name my-container-name -p 6603:3306 -d mysql/mysql-server
145+
146+
## Passing options to the server
147+
148+
You can pass arbitrary command line options to the MySQL server by appending them to the `run command`:
149+
150+
docker run --name my-container-name -d mysql/mysql-server --option1=value --option2=value
151+
152+
In this case, the values of option1 and option2 will be passed directly to the server when it is started. The following command will for instance start your container with UTF-8 as the default setting for character set and collation for all databases in MySQL:
153+
154+
docker run --name my-container-name -d mysql/mysql-server --character-set-server=utf8 --collation-server=utf8_general_ci
155+
140156
## Using a Custom MySQL Config File
141157

142158
The MySQL startup configuration in these Docker images is specified in the file `/etc/my.cnf`. If you want to customize this configuration for your own purposes, you can create your alternative configuration file in a directory on the host machine and then mount this file in the appropriate location inside the MySQL container, effectively replacing the standard configuration file.

0 commit comments

Comments
 (0)