在 docker swarm 中运行的 docker bitnami 图像中使用 git

Use git in a docker bitnami image that runs in docker swarm

我正在 运行 使用 portainer.io 安装标准 magento 图像,问题是标准图像没有默认安装 git,我试图添加 bitnami git 图像到 docker-compose.yml,堆栈 运行 成功但我无法在命令行 git 中访问

docker-compose.yml :

version: '3'
services:
  git:
    image: docker.io/bitnami/git:2
    deploy:
      restart_policy:
        condition: none
  mariadb:
    image: docker.io/bitnami/mariadb:10.3
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_magento
      - MARIADB_DATABASE=bitnami_magento
    volumes:
      - 'mariadb_data:/bitnami/mariadb'
  magento:
    image: docker.io/bitnami/magento:2
    ports:
      - '80:8080'
      - '443:8443'
    environment:
      - MAGENTO_HOST=localhost
      - MAGENTO_DATABASE_HOST=mariadb
      - MAGENTO_DATABASE_PORT_NUMBER=3306
      - MAGENTO_DATABASE_USER=bn_magento
      - MAGENTO_DATABASE_NAME=bitnami_magento
      - ELASTICSEARCH_HOST=elasticsearch
      - ELASTICSEARCH_PORT_NUMBER=9200
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - 'magento_data:/bitnami/magento'
      - 'magento_certs:/certs'
    depends_on:
      - mariadb
      - elasticsearch
      - git
  elasticsearch:
    image: docker.io/bitnami/elasticsearch:7
    volumes:
      - 'elasticsearch_data:/bitnami/elasticsearch/data'
volumes:
  mariadb_data:
    driver: local
  magento_data:
    driver: local
  elasticsearch_data:
    driver: local
  magento_certs:
    driver: local

拥有 Dockerfile:

FROM bitnami/magento:2

RUN apt-get update && apt-get install git -y
$ docker build -t magento-git .

并使用 magento-git 代替 bitnami/magento