0 docker備忘録 #docker #rails みんなに公開

docker備忘録

Dockerfileの作成

# set base OS image
FROM ubuntu:latest

# set Ruby installed Dir
ENV RUBY_DIR /ruby/
ENV RUBY_VERSION 2.6.5
ENV RUBY_INSTALL $RUBY_DIR/$RUBY_VERSION

# install packeges for installing Ruby
RUN apt-get -y update && \
    apt-get -y upgrade && \
    apt-get -y install bzip2 make wget tar git nodejs autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev

# install Ruby with ruby-build
RUN mkdir $RUBY_DIR && \
    cd $RUBY_DIR    && \
    git clone https://github.com/sstephenson/ruby-build.git && \
    $RUBY_DIR/ruby-build/install.sh                         && \
    cd $RUBY_DIR/ruby-build && ./bin/ruby-build $RUBY_VERSION $RUBY_INSTALL && \
    rm -rf $RUBY_DIR/ruby-build
ENV PATH $RUBY_INSTALL/bin:$PATH

RUN apt-get -y install libmysqlclient-dev mysql-server libcurl4-openssl-dev
RUN /etc/init.d/mysql start

RUN gem install passenger
RUN passenger-install-nginx-module --auto --prefix=/opt/nginx

RUN gem install mysql2 && gem install bundler -v 2.0.1
RUN apt-get -y install language-pack-ja-base language-pack-ja ibus-mozc
RUN update-locale LANG=ja_JP.UTF-8

RUN apt-get -y install vim
#RUN apt-get remove --purge resolvconf && apt-get -y install --reinstall resolvconf
RUN apt-get -y install ufw

imageの作成

docker build -t [username]/[imagename] .

tagの作成

docker tag [username]/[imagename]:[old_tagname] [username]/[imagename]:[new_tagname]

コンテナの起動

docker run -it -p 10080:80 -p 13000:3000 -p 13306:3306 -v [host_workdir]:[docker_workdir]  --add-host=local_dev:[hostip] --cap-add=NET_ADMIN [container]

コンテナの中断

ctrl+p ctrl+q

中断したコンテナIDの確認

docker ps -a
<表示>
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES
95f75a637a45        junshimo2/nagaoka   "/bin/bash"         About a minute ago   Exited (0) About a minute ago                       vigorous_nobel

<コンテナIDを覚えておく>

中断したコンテナに戻る

docker attach 95f75a637a45

コンテナの停止

exit

コンテナを再起動してアタッチ

docker start 95f75a637a45
docker attach 95f75a637a45
0

メモを他の人に見せる

このメモを見せたい人に、このURL(今開いているページのURLです)を教えてあげてください

コメント(0)

  • someone

  • someone