-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-portainer.sh
More file actions
38 lines (38 loc) · 930 Bytes
/
install-portainer.sh
File metadata and controls
38 lines (38 loc) · 930 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
#!/bin/bash
#
# https://docs.portainer.io/start/install-ce/server/docker/linux
#
# Exit on error
set -e
#
# SET VARIABLES
# -------------
# Storage location variable (leave blank for default Docker volume)
VOLUME_PATH=""
# -------------
#
# Prepare the volume option based on the storage location provided
if [ -z "$VOLUME_PATH" ]; then
docker volume create portainer_data
volume_option="-v portainer_data:/data"
else
mkdir -p "$VOLUME_PATH"
volume_option="-v $VOLUME_PATH:/data"
fi
#
# Run Portainer container
docker run -d \
-p 9443:9443 \
--name portainer \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
$volume_option \
portainer/portainer-ce:latest
#
# Check if the container is running
if docker container inspect portainer &> /dev/null; then
echo "Portainer is running."
else
echo "Failed to start Portainer."
fi