Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dockerfile CentOS + sshd + Zabbix(Apache, MySQL)
- FROM centos:centos6
- MAINTAINER kaz
- ## yum plugin fastestmirror
- RUN echo "prefer=ftp.iij.ad.jp" >> /etc/yum/pluginconf.d/fastestmirror.conf
- # Time Zone
- RUN echo 'ZONE="Asia/Tokyo"' > /etc/sysconfig/clock
- RUN rm -f /etc/localtime
- RUN ln -fs /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
- # refer to https://www.mail-archive.com/centos@centos.org/msg105095.html
- RUN sed -i 's|mirrorlist=\(.*\)\&repo=updates$|#mirrorlist=\1\&repo=updates|g' /etc/yum.repos.d/CentOS-Base.repo
- RUN sed -i 's|#baseurl=.*updates/$basearch/$|baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/updates/$basearch/|g' /etc/yum.repos.d/CentOS-Base.repo
- RUN yum clean all
- ## Install
- #RUN yum groupinstall -y 'Base'
- RUN yum install -y sudo openssh-server yum-plugin-priorities.noarch yum-plugin-downloadonly
- RUN rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
- RUN rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm
- RUN yum clean all
- RUN yum install -y mysql-community-server
- RUN yum install -y zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql fping iksemel
- RUN yum remove -y zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
- RUN yum install --downloadonly --downloaddir=/tmp -y zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql || echo "OK"
- RUN sed -ri 's/excludedocs 1/excludedocs 0/g' /etc/rpm/macros.imgcreate
- RUN rpm -ivh /tmp/zabbix*
- ## create user
- RUN useradd kaz
- RUN passwd -u -f kaz
- RUN mkdir /home/kaz/.ssh; chown kaz. /home/kaz/.ssh; chmod 700 /home/kaz/.ssh
- ADD ./authorized_keys /home/kaz/.ssh/
- RUN chown kaz. /home/kaz/.ssh/authorized_keys
- RUN chmod 600 /home/kaz/.ssh/authorized_keys
- ## sudo
- RUN echo "kaz ALL=(ALL) ALL" >> /etc/sudoers.d/kaz
- ## sshd
- RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
- RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config
- RUN sed -ri 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/' /etc/ssh/sshd_config
- RUN sed -ri 's/GSSAPIAuthentication yes/#GSSAPIAuthentication yes/' /etc/ssh/sshd_config
- RUN /etc/init.d/sshd start && sleep 5 && /etc/init.d/sshd stop
- #RUN /etc/init.d/sshd stop
- ## mysql & zabbix server
- RUN /etc/init.d/mysqld start && sleep 5 && /etc/init.d/mysqld stop
- RUN echo -e "/etc/init.d/mysqld start\nsleep 5\n/usr/bin/mysql -uroot -e 'create database zabbix character set utf8 collate utf8_bin'" > /home/kaz/zabbix.sql
- RUN echo "/usr/bin/mysql -uroot -e 'grant all privileges on zabbix.* to \"zabbix\"@\"localhost\" identified by \"zabbix\"'" >> /home/kaz/zabbix.sql
- RUN echo "/usr/bin/mysql -uroot zabbix < /usr/share/doc/zabbix-server-mysql-2.0.13/create/schema.sql" >> /home/kaz/zabbix.sql
- RUN echo "/usr/bin/mysql -uroot zabbix < /usr/share/doc/zabbix-server-mysql-2.0.13/create/images.sql" >> /home/kaz/zabbix.sql
- RUN echo -e "/usr/bin/mysql -uroot zabbix < /usr/share/doc/zabbix-server-mysql-2.0.13/create/data.sql\nsleep 5\n/etc/init.d/mysqld stop" >> /home/kaz/zabbix.sql
- RUN chmod u+x /home/kaz/zabbix.sql
- RUN ["/bin/bash","-c","/home/kaz/zabbix.sql"]
- RUN rm -f /etc/zabbix/zabbix_server.conf
- ADD zabbix_server.conf /etc/zabbix/zabbix_server.conf
- ##
- RUN touch /run.sh
- RUN echo -e "#!/bin/bash\n/sbin/service mysqld start\n/sbin/service zabbix-server start\n/sbin/service httpd start\n/sbin/service sshd start\n\nwhile true\ndo\n sleep 10\ndone\n" > /run.sh
- RUN chmod u+x /run.sh
- EXPOSE 22 3306 10050 10051
- CMD ["/run.sh"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement