-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-run.sh
More file actions
executable file
·40 lines (34 loc) · 937 Bytes
/
Copy pathdocker-run.sh
File metadata and controls
executable file
·40 lines (34 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Use this only for running individual containers locally
# On cpouta use docker-compose
IMAGE_NAME="apache-varnish"
CONTAINER_NAME="$IMAGE_NAME"
IP="172.30.23.9"
CONTAINER_PORT="80"
PORT="8080"
NETWORK="seco"
NETWORK_CIDR="172.30.20.0/22"
CONTAINER_USER="$UID"
CONTAINER_PATH_HTML="/var/www/html"
# DOCKER
# Create docker network if it does not exist
docker network inspect "$NETWORK" > /dev/null 2>&1
if [ $? != 0 ]; then
set -x # print the next comand
docker network create --subnet $NETWORK_CIDR $NETWORK
{ set +x; } 2> /dev/null
fi
mkdir -p vol-html
chmod ug+rwX vol-html
#Run the container
set -x # print the next command
docker run -it --rm \
-u $CONTAINER_USER \
--name $CONTAINER_NAME \
--network $NETWORK \
--ip $IP \
--publish $PORT:$CONTAINER_PORT \
--expose $CONTAINER_PORT \
--mount "type=bind,source=$(pwd)/vol-html,target=$CONTAINER_PATH_HTML" \
$IMAGE_NAME
{ set +x; } 2> /dev/null