weichao
weichao

Reputation: 3381

How to pass start args to docker compose file like docker run --opts?

I have write a docker compose file, I want to start compose use

docker-compose up -d

But I want to pass args to my images It look like

docker run --security-opt=seccomp:unconfined mysql:8.0

But I find compose file only have basic config such as network, volume, environment

My compose file

db:
image: mysql:8.0
container_name: onlinecodedb
volumes:
  - onlinecode-database:/var/lib/mysql
environment:
  MYSQL_ROOT_PASSWORD: mysqlrootpassword
  MYSQL_PASSWORD: mysqlpassword
  MYSQL_USER: mysql
  MYSQL_DATABASE: onlinecode
ports:
  - "3300:3306"
networks:
  - onlinecode-net

How I solve this problem?

Upvotes: 0

Views: 2377

Answers (1)

David Maze
David Maze

Reputation: 159156

Most of the docker run options have matching Docker Compose options. In particular, docker run --security-opt maps to a security_opt: field.

db:
  image: 'mysql:8.0'
  security_opt:
    - 'seccomp:unconfined'
  et: cetera

Upvotes: 4

Related Questions