我在gcp上使用了一个启动脚本,它在示例启动时启动一个docker compose文件。
这个问题来自于docker-compose,如果我以jeorfevre启动它,或者如果我以gcp用户(启动脚本)启动它们,它不会启动相同的卷名。似乎卷名被重写了-我如何修复在docker compose中使用的卷名,而不管用户启动它们?
我想总是启动jeorfevre_mariadb_data,但他却尝试启动_mariadb_data。
谢谢你的帮助。
GCP启动脚本:
echo " --------------------- STARTUP SCRIPT ---------------------------"
echo " - chechup "
docker version
docker volume ls
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/suitecrm/docker-compose.yml > docker-compose.yml
echo " - Current user $USER"
sudo docker compose up -d
echo " ----------- END -----------"
停靠器合成文件
version: '2'
services:
mariadb:
image: docker.io/bitnami/mariadb:10.6
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_suitecrm
- MARIADB_DATABASE=bitnami_suitecrm
- MARIADB_PASSWORD=bitnami123
volumes:
- 'mariadb_data:/bitnami/mariadb'
suitecrm:
image: docker.io/bitnami/suitecrm:8
ports:
- '80:8080'
- '443:8443'
environment:
- SUITECRM_DATABASE_HOST=mariadb
- SUITECRM_DATABASE_PORT_NUMBER=3306
- SUITECRM_DATABASE_USER=bn_suitecrm
- SUITECRM_DATABASE_NAME=bitnami_suitecrm
- SUITECRM_DATABASE_PASSWORD=bitnami123
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'suitecrm_data:/bitnami/suitecrm'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
suitecrm_data:
driver: local
GCP日志:
Mar 22 09:16:30 crm2-vm google_metadata_script_runner[1094]: startup-script: --------------------- STARTUP SCRIPT ---------------------------
Mar 22 09:16:30 crm2-vm google_metadata_script_runner[1094]: startup-script: - chechup
Ubuntu 20.04.6 LTS crm2-vm ttyS0
crm2-vm login: Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Client: Docker Engine - Community
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Version: 23.0.1
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: API version: 1.42
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Go version: go1.19.5
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Git commit: a5ee5b1
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Built: Thu Feb 9 19:46:56 2023
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: OS/Arch: linux/amd64
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Context: default
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script:
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Server: Docker Engine - Community
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Engine:
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Version: 23.0.1
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: API version: 1.42 (minimum version 1.12)
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Go version: go1.19.5
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Git commit: bc3805a
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Built: Thu Feb 9 19:46:56 2023
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: OS/Arch: linux/amd64
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Experimental: false
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: containerd:
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Version: 1.6.18
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: GitCommit: 2456e983eb9e37e47538f59ea18f2043c9a73640
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: runc:
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Version: 1.1.4
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: GitCommit: v1.1.4-0-g5fd4c4d
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: docker-init:
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: Version: 0.19.0
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: GitCommit: de40ad0
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: DRIVER VOLUME NAME
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: local jeorfevre_mariadb_data
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: local jeorfevre_suitecrm_data
Mar 22 09:16:31 crm2-vm google_metadata_script_runner[1094]: startup-script: - Current user
Mar 22 09:16:32 crm2-vm google_metadata_script_runner[1094]: startup-script: Volume "_mariadb_data" Creating
Mar 22 09:16:32 crm2-vm google_metadata_script_runner[1094]: startup-script: Volume "_mariadb_data" Error
Mar 22 09:16:32 crm2-vm google_metadata_script_runner[1094]: startup-script: Error response from daemon: create _mariadb_data: "_mariadb_data" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
Mar 22 09:16:32 crm2-vm google_metadata_script_runner[1094]: startup-script: ----------- END -----------
1条答案
按热度按时间xlpyo6sf1#
我已经找到了解决方案,并与社区分享。
您必须设置目录名,以便设置正确的卷名“compose -p”:
https://forums.docker.com/t/docker-compose-prepends-directory-name-to-named-volumes/32835