@@ -9,6 +9,13 @@ if [ -f /.dockerenv ]; then
99 exit
1010fi
1111
12+ export DOCKER_COMPOSE_COMMAND=" docker-compose"
13+
14+ # Support newer version of docker that have docker compose built in
15+ if [[ ! $( which docker-compose) ]]; then
16+ DOCKER_COMPOSE_COMMAND=" docker compose"
17+ fi
18+
1219# Used as the prefix for docker networking, container naming and nginx hostname.
1320export PROJECT=$( basename ${PWD} )
1421# docker-compose stopped stripping chars from project name in 1.21.0.
@@ -53,7 +60,7 @@ error() {
5360# Configures environment then brings up project using docker-compose.yml file.
5461dsh_start () {
5562 notice " Starting project containers."
56- docker-compose -f ${DOCKER_COMPOSE_FILE} up -d
63+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} up -d
5764 export URL=" http://127.0.0.1"
5865 notice " Please wait about 10 seconds for the database to settle.
5966You can now access the site from ${URL} .
@@ -67,7 +74,7 @@ Connecting via ./dsh shell and running robo build is a common next step."
6774dsh_shell () {
6875 dsh_start
6976
70- docker-compose -f ${DOCKER_COMPOSE_FILE} exec \
77+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} exec \
7178 -e COLUMNS=" $( tput cols) " \
7279 -e LINES=" $( tput lines) " \
7380 web ${@:- ./ dsh_bash}
@@ -77,13 +84,13 @@ dsh_shell() {
7784# Stops project and brings down network after disconnecting nginx proxy.
7885dsh_stop () {
7986 notice " Stopping containers."
80- docker-compose -f ${DOCKER_COMPOSE_FILE} stop
87+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} stop
8188}
8289
8390# Command: ./dsh down
8491# Stops project, then takes down containers and removes volumes if possible.
8592dsh_down () {
86- docker-compose -f ${DOCKER_COMPOSE_FILE} down -v
93+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} down -v
8794}
8895
8996# Command: ./dsh purge
@@ -96,13 +103,13 @@ dsh_purge() {
96103# Command: ./dsh status
97104# Shows status information about project containers.
98105dsh_status () {
99- docker-compose -f ${DOCKER_COMPOSE_FILE} ps
106+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} ps
100107}
101108
102109# Command: ./dsh logs
103110# Tails logs from web container.
104111dsh_logs () {
105- docker-compose -f ${DOCKER_COMPOSE_FILE} logs -f web
112+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} logs -f web
106113}
107114
108115dsh_project () {
@@ -117,9 +124,9 @@ dsh_project() {
117124# Fetches all images used by the project.
118125dsh_pull () {
119126 # docker-compose doesn't resolve sub-dependencies in Dockerfiles and that's ok.
120- docker-compose -f ${DOCKER_COMPOSE_FILE} pull --ignore-pull-failures
127+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} pull --ignore-pull-failures
121128 # Check for dependent image updates with --pull before building.
122- docker-compose -f ${DOCKER_COMPOSE_FILE} build --pull
129+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} build --pull
123130}
124131
125132# Command: ./dsh nfs
@@ -164,7 +171,7 @@ dsh_setup_nfs() {
164171 while ! docker ps > /dev/null 2>&1 ; do sleep 2; done
165172
166173 echo " == Stopping running docker containers..."
167- docker-compose -f ${DOCKER_COMPOSE_FILE} down > /dev/null 2>&1
174+ ${DOCKER_COMPOSE_COMMAND} -f ${DOCKER_COMPOSE_FILE} down > /dev/null 2>&1
168175 docker volume prune -f > /dev/null
169176
170177 osascript -e ' quit app "Docker"'
0 commit comments