Skip to content

Instantly share code, notes, and snippets.

@hayajo
Last active April 12, 2017 00:02
Show Gist options
  • Save hayajo/6cc787f4e8c4aee8616c to your computer and use it in GitHub Desktop.
Save hayajo/6cc787f4e8c4aee8616c to your computer and use it in GitHub Desktop.
RackTablesつかってみようず(Docker版)

RackTables使ってみようず(Docker版)

RackTables

db name : racktables_db

db user : racktables_user

db password : racktables_password

Usage

Build image and run container.

$ docker build -t racktables .
$ docker run -itd --name racktables racktables

Check the container ip address.

$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' racktables

Access to the racktables and setting up.

http://<IPAddress>/?module=installer

When instructed change the owner on "secret.php", execute the "chsecret.sh".

$ docker attach racktables
docker# /usr/local/share/racktables/chsecret.sh
docker# <Ctrl-p> <Ctrl-q>  # detach container

Enjoy.

#!/bin/bash
secret=/var/www/html/inc/secret.php
chown apache:apache $secret && chmod 400 $secret
FROM centos:centos6
RUN yum install -y mysql mysql-server php php-mysql php-pdo php-gd php-mbstring php-bcmath httpd tar
RUN curl -L -o RackTables-latest.tar.gz 'http://sourceforge.net/projects/racktables/files/latest/download?source=files'
RUN tar xzf RackTables-latest.tar.gz
RUN cd $(find -type d -name 'RackTables-*') && rmdir /var/www/html && cp -a wwwroot /var/www/html
RUN touch /var/www/html/inc/secret.php && chmod 666 /var/www/html/inc/secret.php
ADD init.sql /usr/local/share/racktables/init.sql
RUN service mysqld start && cat /usr/local/share/racktables/init.sql | mysql -u root
ADD chsecret.sh /usr/local/share/racktables/chsecret.sh
RUN chmod +x /usr/local/share/racktables/chsecret.sh
ADD start.sh /usr/local/bin/start
RUN chmod +x /usr/local/bin/start
ADD stop.sh /usr/local/bin/stop
RUN chmod +x /usr/local/bin/stop
CMD ["/usr/local/bin/start"]
CREATE DATABASE racktables_db DEFAULT CHARACTER SET = 'utf8';
GRANT ALL ON racktables_db.* TO racktables_user@localhost IDENTIFIED BY 'racktables_password';
#!/bin/bash
service httpd start
service mysqld start
cat <<EOF >~/.bashrc
trap '/usr/local/bin/stop; exit 0' TERM
EOF
exec /bin/bash
#!/bin/bash
service httpd stop
service mysqld stop
@puppetmaster886
Copy link

it fail whe try to use it with boot2docker.
There are two issues here.

That Dockerfile was doing modifications to kernel parameters at build-time, but those modifications would not carry over to run-time. In other words, the sysctl would be executed during the build, but have no effect on the run.

Those modifications shouldn't even be allowed inside containers (except when they are implemented per-namespace). If you need to tune those parameters, you should do that outside of Docker, or in a privileged container.

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