ERROR: The Compose file './docker-compose.yml' is invalid because: services.mongo.environment contains {"MONGO_INITDB_ROOT_USERNAME": "root"}, which is an invalid type, it should be a string
3.2 运行
使用docker-compose up命令可以直接启动。如果不希望有输出信息,则使用docker-compose up -d来启动。启动后,使用docker-compose ps命令查看运行状态:
1 2 3 4 5 6 7
docker-compose ps Name Command State Ports ---------------------------------------------------------------------------------- foomongo docker-entrypoint.sh mongod Up 27017/tcp foomongo-express tini -- /docker-entrypoint ... Up 0.0.0.0:8081->8081/tcp foomysql docker-entrypoint.sh mysql ... Up 0.0.0.0:3306->3306/tcp fooredis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
root@latelee:/home/latelee/docker/composefile/mysql_test# docker exec -it foomysql bash # 进入容器 root@61858ee65fd1:/# mysql -uroot -proot # 使用root进入MySQL Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.45 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
1、本文所述“docker-compose文件”,——包括作者日常交流,都是指“docker-compose.yml”这个文件。而“docker-compose”则是指docker-compose这个工具本身。 2、默认情况下,直接使用docker-compose up -d命令启动即可。此时,docker-compose工具会在当前目录查找docker-compose.yml文件,并以目录名称作为工程名称。如果需要更改,则使用-f来指定docker-compose文件,-p指定工程名称。 3、docker-compose也有类似的