Xóa bài viết
Bạn có chắc chắn muốn xóa bài viết này không ?
Xóa bình luận
Bạn có chắc chắn muốn xóa bình luận này không ?
Docker shit
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

{{ comment.user.name }}
Bỏ hay
Hay

Cùng một tác giả