我正在使用docker-app生成的docker-compose文件
docker-app render | docker-compose -f - up
docker应用程序文件如下所示,并且可以正常工作。但是我无法使用卷。
我在使用docker run命令时使用-v参数...
-v /my/custom3399:/etc/mysql/conf.d
-v /storage/mysql/datadir3399:/var/lib/mysql
如何在撰写文件中声明卷?
# vi hello.dockerapp
# This section contains your application metadata.
# Version of the application
version: 0.1.0
# Name of the application
name: hello
# A short description of the application
description:
# Namespace to use when pushing to a registry. This is typically your Hub username.
#namespace: myHubUsername
# List of application maitainers with name and email for each
maintainers:
- name: root
email:
# Specify false here if your application doesn't support Swarm or Kubernetes
targets:
swarm: false
kubernetes: false
--
# This section contains the Compose file that describes your application services.
version: "3.5"
services:
mysql:
image: ${mysql.image.version}
environment:
MYSQL_ROOT_PASSWORD: india${mysql.port}
ports:
- "${mysql.port}:3306"
--
# This section contains the default values for your application settings.
mysql.image.version: shantanuo/mysql:5.7
mysql.port: 3391
更新:
上面提到的脚本效果很好。但是一旦添加卷,就会收到错误消息:
version: "3.5"
services:
mysql:
image: ${mysql.image.version}
environment:
MYSQL_ROOT_PASSWORD: india${mysql.port}
ports:
- "${mysql.port}:3306"
volumes:
- type: volume
source: mysql_data
target: /var/lib/mysql
volumes:
mysql_data:
external: true
错误是:
docker-app render | docker-compose -f - up
Recreating e5c833e2187d_hashi_mysql_1 ... error
ERROR: for e5c833e2187d_hashi_mysql_1 Cannot create container for service mysql: Duplicate mount point: /var/lib/mysql
ERROR: for mysql Cannot create container for service mysql: Duplicate mount point: /var/lib/mysql
ERROR: Encountered errors while bringing up the project.
如评论中所述,呈现的输出如下:
# /usr/local/bin/docker-app render
version: "3.5"
services:
mysql:
environment:
MYSQL_ROOT_PASSWORD: india3391
image: shantanuo/mysql:5.7
ports:
- mode: ingress
target: 3306
published: 3391
protocol: tcp
volumes:
- type: volume
source: mysql_data
target: /var/lib/mysql
volumes:
mysql_data:
name: mysql_data
external: true
答案 0 :(得分:0)
更改目录名称后,此问题已解决。
# cd ..
# mv hashi/ hashi123/
# cd hashi123
不确定如何运作。但是,由于我能够启动服务器堆栈,因此将其发布为答案。