Skip to content

Commit a0318db

Browse files
committed
Merge pull request gogs#239 from baijum/docker_command
use 'docker.io' command instead of 'docker'
2 parents 4f2f3c2 + c6058e5 commit a0318db

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

dockerfiles/build.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ HOST_PORT="YOUR_HOST_PORT" # The port on host, which will be redirected t
1010
# apt source, you can select 'nchc'(mirror in Taiwan) or 'aliyun'(best for mainlance China users) according to your network, if you could connect to the official unbunt mirror in a fast speed, just leave it to "".
1111
APT_SOURCE=""
1212

13+
DOCKER_BIN=$(which docker.io || which docker)
14+
if [ -z "$DOCKER_BIN" ] ; then
15+
echo "Please install docker. You can install docker by running \"wget -qO- https://get.docker.io/ | sh\"."
16+
exit 1
17+
fi
18+
1319
# Replace the database root password in database image Dockerfile.
1420
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile
1521
# Replace the database root password in gogits image deploy.sh file.
@@ -36,22 +42,22 @@ if [ $MEM_TYPE != "" ]
3642
sed -i "${GOGS_BUILD_LINE}s/$/ -tags $MEM_TYPE/" images/gogits/Dockerfile
3743

3844
cd images/$MEM_TYPE
39-
docker build -t gogits/$MEM_TYPE .
40-
docker run -d --name $MEM_RUN_NAME gogits/$MEM_TYPE
45+
$DOCKER_BIN build -t gogits/$MEM_TYPE .
46+
$DOCKER_BIN run -d --name $MEM_RUN_NAME gogits/$MEM_TYPE
4147
MEM_LINK=" --link $MEM_RUN_NAME:mem "
4248
cd ../../
4349
fi
4450

4551
# Build the database image
4652
cd images/$DB_TYPE
47-
docker build -t gogits/$DB_TYPE .
53+
$DOCKER_BIN build -t gogits/$DB_TYPE .
4854
#
4955

5056

5157
## Build the gogits image
5258
cd ../gogits
5359

54-
docker build -t gogits/gogs .
60+
$DOCKER_BIN build -t gogits/gogs .
5561

5662
#sed -i "s#RUN go get -u -tags $MEM_TYPE github.com/gogits/gogs#RUN go get -u github.com/gogits/gogs#g" Dockerfile
5763

@@ -60,9 +66,9 @@ sed -i "s/ -tags $MEM_TYPE//" Dockerfile
6066

6167
#
6268
## Run MySQL image with name
63-
docker run -d --name $DB_RUN_NAME gogits/$DB_TYPE
69+
$DOCKER_BIN run -d --name $DB_RUN_NAME gogits/$DB_TYPE
6470
#
6571
## Run gogits image and link it to the database image
6672
echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:"
67-
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db $MEM_LINK -p $HOST_PORT:3000 gogits/gogs \033[0m"
73+
echo -e "\033[33m $DOCKER_BIN run -i -t --link $DB_RUN_NAME:db $MEM_LINK -p $HOST_PORT:3000 gogits/gogs \033[0m"
6874

dockerfiles/run.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ typeset -u MYSQL_ALIAS
55
MYSQL_ALIAS="db"
66
HOST_PORT="3000"
77

8+
DOCKER_BIN=$(which docker.io || which docker)
9+
if [ -z "$DOCKER_BIN" ] ; then
10+
echo "Please install docker. You can install docker by running \"wget -qO- https://get.docker.io/ | sh\"."
11+
exit 1
12+
fi
13+
814
## Run MySQL image with name
9-
docker run -d --name $MYSQL_RUN_NAME gogs/mysql
15+
$DOCKER_BIN run -d --name $MYSQL_RUN_NAME gogs/mysql
1016
#
1117
## Run gogits image and link it to the MySQL image
12-
docker run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits
18+
$DOCKER_BIN run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits
1319

0 commit comments

Comments
 (0)