Public Repository

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Settings

For Mac

$ boot2docker upgrade
$ boot2docker init
$ VBoxManage sharedfolder add boot2docker-vm --name Users --hostpath $HOME

$ boot2docker up && boot2docker ssh

nsenterのコンテナ起動( docker-enterコマンド実行環境)

$ docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter

centos7-nginxのコンテナイメージ取得

$ docker pull gorohayakawa/centos7-nginx:latest

Start Container

$ docker run --privileged -it -v /Users/work:/work -P -d --name centos7-nginx gorohayakawa/centos7-nginx:latest

(Macのboot2dockerではホストPC の$HOME/workがコンテナの/workにマウントされて共有ディレクトリとなる)

Login Container

$ docker-enter centos7-nginx

or

$ docker exec -it centos7-nginx bash

Dockerfile

FROM centos:centos7
MAINTAINER Goro Hayakawa "hayao56@gmail.com"
ENV container docker

# install systemd
RUN \
  exec >& /root/build-systemd.log ;\
  set -eux ;\
  yum swap -y fakesystemd systemd initscripts epel-release vim ;\
  unlink /etc/localtime ;\
  ln -s /usr/share/zoneinfo/Japan /etc/localtime ;\
  localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 ;\
  rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm ;\
  yum clean all ;\
  echo ;\
  echo "export HOME=/root" > /root/.bashrc ;\
  echo "export EDITOR=vim" >> /root/.bashrc ;\
  echo "export LANG=ja_JP.UTF-8" >> /root/.bashrc ;\
  echo "alias ls='ls --color'" >> /root/.bashrc ;\
  echo "alias vi='vim -p'" >> /root/.bashrc ;\
  echo "alias vim='vim -p'" >> /root/.bashrc ;\
  echo ;\
  echo "set smartindent" > /root/.vimrc ;\
  echo "set nowrapscan" >> /root/.vimrc ;\
  echo "set nowrap" >> /root/.vimrc ;\
  echo "set nu" >> /root/.vimrc ;\
  echo "colorscheme desert" >> /root/.vimrc ;\
  echo "highlight DiffAdd    cterm=bold ctermfg=10 ctermbg=22" >> /root/.vimrc ;\
  echo "highlight DiffDelete cterm=bold ctermfg=10 ctermbg=52" >> /root/.vimrc ;\
  echo "highlight DiffChange cterm=bold ctermfg=10 ctermbg=17" >> /root/.vimrc ;\
  echo "highlight DiffText   cterm=bold ctermfg=10 ctermbg=21" >> /root/.vimrc ;\
  echo ;\
  echo "[user]" > /root/.gitconfig ;\
  echo "    email = root@localhost.localdomain" >> /root/.gitconfig ;\
  echo "    name = root" >> /root/.gitconfig ;\
  echo "[info] done."

# root password settings
RUN yum -y install passwd ;
RUN echo 'root:root' | chpasswd ;

# install wget
RUN yum -y install wget ;

# install gpg-key
RUN wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 ;
RUN rpm --import RPM-GPG-KEY-EPEL-7 ;

RUN wget http://nginx.org/packages/keys/nginx_signing.key ;
RUN rpm --import nginx_signing.key ;
RUN yum list|grep nginx ;

# install nginx
RUN echo '[nginx]' > /etc/yum.repos.d/nginx.repo ;
RUN echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo ;
RUN echo 'baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo ;
RUN echo 'gpgcheck=1' >> /etc/yum.repos.d/nginx.repo ;
RUN echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo ;
RUN yum -y --enablerepo=nginx install nginx ;

EXPOSE 80
EXPOSE 443

RUN systemctl enable nginx

ENTRYPOINT ["/sbin/init"]
Docker Pull Command
Owner
gorohayakawa

Comments (0)