Docker shit
White

t viết ngày 26/08/2016

Create a dockerfile

$ mkdir ~/home/containers/develop
$ cd develop
$ emacs -nw Dockerfiles

Paste these content into emacs

FROM ubuntu:14.04
MAINTAINER Thanh Pham <thanh@leflair.vn>

RUN apt-get update -qq && apt-get install -y ca-certificates \
  git \
   wget \
  xz-utils \
  g++ \
  gcc \
  libc6-dev \
  make

# set up nodejs and install some basic packages
RUN wget https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-x64.tar.xz
RUN tar xf node-v4.5.0-linux-x64.tar.xz
RUN cp node-v4.5.0-linux-x64/ /opt/node-v4.5 -R
ENV PATH $PATH:/opt/node-v4.5/bin
RUN /opt/node-v4.5/bin/npm install -g tsc mocha chai grunt bower

Build an image based on the Dockerfile

Ok, let's build the an image.

docker build -t thanhpk/develop .

optional, push it to docker hub if you want

docker login
docker push thanhpk/develop

Create a new container based on the image

Start a new container by typing

docker run -dit --name dev thanhpk/develop 

Now you can see a new running container in docker ps named dev. To connect with it, use

docker exec -it dev /bin/bash

Modify the container

For example, if you want to share a directory of the container with the host, you must create a new container.
Instead of create a fresh new instance of container based on the image (docker run -dit -v /tmp:/tmp2 --name dev2 thanhpk/develop, you could attach a new volume to the container based on existing container, by using commit

# dev is name of the container, the following comand will create a new image based on dev
docker commit dev imageforcurrentdev
docker run -dit -v tmp:/tmp2 imageforcurrentdev --name dev2

Whoola,

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

White

t

5 bài viết.
0 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
White
1 0
sudo du sh
t viết gần 2 năm trước
1 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


White
{{userFollowed ? 'Following' : 'Follow'}}
5 bài viết.
0 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!