Home Docker Docker Compose运行多个command
Post
Cancel

Docker Docker Compose运行多个command

refer to:
https://www.baeldung.com/ops/docker-compose-multiple-commands

这是一个例子;

version: '3'
services:

  mysql5.7:
    container_name: "mysql5.7"
    image: mysql:5.7
    volumes:
      - /opt/docker_folder/mysql5.7:/var/lib/mysql
    #command: 'tail -F /dev/null'
    #command: 'mysqld'
    command:                       # 这个command 运行多个命令,必须这样写才好使。不要考虑 && 这个用法
      - /bin/sh
      - -c
      - |
        chmod 777 /tmp
        mysqld
    ports:
      - "3306:3306"
    stdin_open: true
    tty: true
    environment:
      - MYSQL_ROOT_PASSWORD=666666
      - MYSQL_ROOT_HOST=%
This post is licensed under CC BY 4.0 by the author.