Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Last active December 10, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZiTAL/5d7c0abf94cea553f67828e0baa0e6bc to your computer and use it in GitHub Desktop.
Save ZiTAL/5d7c0abf94cea553f67828e0baa0e6bc to your computer and use it in GitHub Desktop.
docker laradock
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from sys import exit, argv
from getpass import getuser
from subprocess import getoutput
from re import findall, MULTILINE
user = getuser()
if user != 'root':
print("root required")
exit()
deny = ['lo', 'eth1', 'vboxnet0']
c = 'systemctl stop docker'
print(c)
getoutput(c)
c = 'ip addr show'
r = getoutput(c)
o = findall(r"[0-9]+:\s+([^:]+):", r, MULTILINE)
for interface in o:
if interface in deny:
pass
else:
c = "ip link set "+interface+" down"
print(c)
getoutput(c)
if len(argv)>1 and argv[1] == 'stop':
print('docker stopped')
else:
c = 'systemctl start docker'
getoutput(c)
print('docker reseted')
# nginx martxan imiñi
docker-compose up -d nginx
# docker-en kontenedoriek gelditsu
docker-compose stop
# bash-era konekta
docker-compose exec -u laradock workspace bash
# bash-era konekta root moduen
docker-compose exec -u root workspace bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment