I want to assign a value to the drupal 'image' tag in a Docker-compose file.
docker-compose.yml
version: '3'
services:
drupal:
image: jonasvbogaert/digipolis-migration:latest
container_name: drupalenv
ports:
- 8080:80
volumes:
- ../drupal_site_eloket-brandweerzonecentrum/:/var/www/html/
restart: always
environment:
DRUPAL_SITE_NAME: Drupal
DRUPAL_USER: admin
DRUPAL_PASS: admin
mariadb:
image: mariadb:latest
container_name: mariadbenv
restart: always
ports:
- 3036:3036
depends_on:
- drupal
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
With the help of a shell script I want to ask the user what Drupal version they want to use. Based on their answer (7 or 8) I want the image value to switch between 2 images.
You can use environment variables in docker-compose.yml
. Change below
image: jonasvbogaert/digipolis-migration:latest
to
image: jonasvbogaert/digipolis-migration:${DRUPAL_VERSION}
In your bash script you would use
export DRUPAL_VERSION=8 #will come from the user
docker-compose up -d
Both the images with given tag should actually exist beforehand. If you need to build them manually then you can use build args in your Dockerfile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.