Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commandline arguments in docker-compose

Tags:

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.

like image 876
Richard Løvehjerte Avatar asked Apr 15 '16 07:04

Richard Løvehjerte


People also ask

How do I give commands in docker compose?

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.

Does docker compose command override ENTRYPOINT?

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.

How do I validate a docker compose file?

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.


1 Answers

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]
like image 78
VonC Avatar answered Oct 01 '22 15:10

VonC