Skip to content

Instantly share code, notes, and snippets.

@aputs
Last active September 11, 2016 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aputs/7804481 to your computer and use it in GitHub Desktop.
Save aputs/7804481 to your computer and use it in GitHub Desktop.
docker centos install
sudo wget --no-check-certificate https://get.docker.io/builds/Linux/x86_64/docker-latest -O /usr/bin/docker
sudo chmod +x /usr/bin/docker
sudo groupadd docker
sudo usermod -a -G docker wyrls
sudo yum install bridge-utils lxc
sudo sysctl -w net.ipv4.ip_forward=1
##/etc/sysctl.conf
sysctl net.ipv4.ip_forward=1
sudo mkdir /cgroup
##/etc/fstab
none /cgroup cgroup defaults 0 0
cat << EOF | sudo tee /etc/sysconfig/network-scripts/ifcfg-docker0
DEVICE=docker0
ONBOOT=yes
TYPE=Bridge
NETMASK=255.255.0.0
IPADDR=172.88.0.1
STP=off
DELAY=0
EOF
iptables -F -t nat
ifconfig docker0 down
brctl delbr docker0
brctl addbr docker0
ifconfig docker0 172.88.0.1 netmask 255.255.0.0 up
docker -d -D
## cleanup mounted (on fedora) / docker unmounts on exit
mount | grep var/lib/docker | cut -d' ' -f3 | xargs sudo umount
sudo chmod +x /etc/init.d/docker
#### centos docker init script
#!/bin/bash
### BEGIN INIT INFO
# INIT INFO
# Provides: docker
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: docker
# Description: docker
### END INIT INFO
. /etc/init.d/functions
NAME=docker
PID_FILE="/var/run/${NAME}.pid"
DELAY=0
status_q() {
status -p $PID_FILE $NAME > /dev/null
return $?
}
start_app() {
nohup /usr/bin/docker -d >/var/log/docker.log 2>&1 </dev/null &
return $?
}
check_config() {
# Do not start if there is no config file.
# [ ! -f "$CONFIG_FILE" ] && return 6
return 0
}
start() {
status_q; res=$?
if [ $res -eq 3 ]; then
echo -n $"$NAME starting..."
start_app
echo $! > $PID_FILE
[ $DELAY -gt 0 ] && sleep $DELAY
status_q; res=$?
[ $res -eq 0 ] && success || failure
echo
elif [ $res -eq 0 ]; then
success; echo "$NAME is already running"
else
failure; echo "$NAME is not running, res: $res"
fi
return $res
}
stop() {
status_q; res=$?
if [ $res -eq 3 ]; then
success && echo "$NAME is not running"
else
killproc -p $PID_FILE; res=$?
if [ $res -eq 0 ]; then
rm -f PID_FILE
success && echo "$NAME has been stopped"
else
failure && echo "$NAME cannot be stopped ($res)"
fi
fi
return $res
}
case $1 in
start)
start
exit $?
;;
stop)
stop
exit $?
;;
status)
echo -n $"$NAME running..."
status_q; res=$?
[ $res -eq 0 ] && success || failure
echo
exit $res
;;
restart)
stop
start
exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 2
;;
esac
@AliMD
Copy link

AliMD commented Sep 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment