This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_docker.sh
executable file
·67 lines (61 loc) · 2.07 KB
/
run_docker.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
#
# Start docker container for Ansible development.
#
# Usage: [OPTIONS] ./run_docker.sh [DISTRO]
# - distro: a supported Docker distro version (default = "centos7")
# Exit on any individual command failure.
set -e
# Pretty colors.
red='\033[0;31m'
green='\033[0;32m'
neutral='\033[0m'
# Allow environment variables to override defaults.
distro=${distro:-"ubuntu:18.04"}
port=${port:-"5000"}
## Override distro with argument
if [ $# -gt 0 ]; then
distro=$1
fi
## Set up vars for Docker setup.
# CentOS 7
if [ $distro = 'centos:7' ]; then
init="/usr/lib/systemd/systemd"
opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# CentOS 6
elif [ $distro = 'centos:6' ]; then
init="/sbin/init"
opts="--privileged"
# Ubuntu 18.04
elif [ $distro = 'ubuntu:18.04' ]; then
init="/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Ubuntu 16.04
elif [ $distro = 'ubuntu:16.04' ]; then
init="/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Ubuntu 14.04
elif [ $distro = 'ubuntu:14.04' ]; then
init="/sbin/init"
opts="--privileged --volume=/var/lib/docker"
# Debian 9
elif [ $distro = 'debian:9' ]; then
init="/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Debian 8
elif [ $distro = 'debian:8' ]; then
init="/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Fedora 24
elif [ $distro = 'fedora:24' ]; then
init="/usr/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Fedora 27
elif [ $distro = 'fedora:27' ]; then
init="/usr/lib/systemd/systemd"
opts="--privileged --volume=/var/lib/docker --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
fi
# Run the container using the supplied OS.
printf ${green}"Starting Docker container: $distro."${neutral}"\n"
docker pull $distro
docker run -v `pwd`:/src -w /src -p $port:$port -it --rm --name ansible $distro bash