The mysql
image for docker allows configuration parameters when running the container.
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
How is this achievable with docker-compose?
I've tried doing -command
but I couldn't get it to work.
Running Single Command Docker Compose allows us to execute commands inside a Docker container. During the container startup, we can set any command via the command instruction. In the above docker-compose. yml file, we are executing a single echo command inside the alpine Docker image.
All About Docker Compose Override Entrypoint Entrypoint helps use set the command and parameters that executes first when a container is run. In fact, the command line arguments in the following command become a part of the entrypoint command, thereby overriding all elements mentioned via CMD.
Validating your file now is as simple as docker-compose -f docker-compose. yml config . As always, you can omit the -f docker-compose. yml part when running this in the same folder as the file itself or having the COMPOSE_FILE environment variable pointing to your file.
Considering mysql image Dockerfile has a CMD
set to mysqld
, you would need to include it to your docker-compose.yml
v2 command
:
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
Or try:
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With