我在Docker上做了一个Drupal项目。我从官方图片开始。我做了这样的docker-compose:
version: "3"
services:
nginx:
build:
context: docker/nginx
dockerfile: Dockerfile
volumes:
- drupal:/var/www/html
ports:
- 80:80
env_file:
- ./docker/env/nginx.env
command: /bin/bash -c "sh /build_vhost.sh"
cli:
build:
context: docker/cli
dockerfile: Dockerfile
args:
DOCKER_UID: ${DOCKER_UID} # replace by your user id
DOCKER_GID: ${DOCKER_GID} # replace by your group id
volumes:
- drupal:/var/www/html
working_dir: /var/www/html
env_file:
- ./docker/env/mysql.env
drupal:
build:
context: docker/drupal
dockerfile: Dockerfile
args:
DOCKER_UID: ${DOCKER_UID} # replace by your user id
DOCKER_GID: ${DOCKER_GID} # replace by your group id
volumes:
- drupal:/var/www/html
working_dir: /var/www/html
restart: always
mariadb:
image: mariadb:10.4-bionic
ports:
- 3306:3306
volumes:
- ./docker/volumes/mariadb/databases:/var/lib/mysql
env_file:
- ./docker/env/mysql.env
volumes:
drupal:
而且可行,我在容器nginx
,cli
和drupal
中有Drupal文件。
但是,如果我将其修改为在项目中包含文件,则如下所示:
version: "3"
services:
nginx:
build:
context: docker/nginx
dockerfile: Dockerfile
volumes:
- ./drupal:/var/www/html
ports:
- 80:80
env_file:
- ./docker/env/nginx.env
command: /bin/bash -c "sh /build_vhost.sh"
cli:
build:
context: docker/cli
dockerfile: Dockerfile
args:
DOCKER_UID: ${DOCKER_UID} # replace by your user id
DOCKER_GID: ${DOCKER_GID} # replace by your group id
volumes:
- ./drupal:/var/www/html
working_dir: /var/www/html
env_file:
- ./docker/env/mysql.env
drupal:
build:
context: docker/drupal
dockerfile: Dockerfile
args:
DOCKER_UID: ${DOCKER_UID} # replace by your user id
DOCKER_GID: ${DOCKER_GID} # replace by your group id
volumes:
- ./drupal:/var/www/html
working_dir: /var/www/html
restart: always
mariadb:
image: mariadb:10.4-bionic
ports:
- 3306:3306
volumes:
- ./docker/volumes/mariadb/databases:/var/lib/mysql
env_file:
- ./docker/env/mysql.env
Drupal文件不在容器中,而是卷工作:如果我在容器中创建文件,则将其保存在本地文件系统中。在建立映像之前,该目录已存在,我在其上放置了777个权限。
在构建中显示Drupal文件已下载并解压缩时的输出。
我不更改两个版本的docker-compose之间的Dockerfile
。
请问如何在本地文件系统上保存Drupal文件以对更改进行版本控制?