Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:docker [2015/05/04 19:28]
stwn [Creating Docker Image] minor fix
doc:docker [2015/05/08 10:41] (current)
stwn [Creating Custom Docker Image] minor fix
Line 7: Line 7:
   * Install docker.io with:<​code>#​ apt-get install docker.io</​code>​   * Install docker.io with:<​code>#​ apt-get install docker.io</​code>​
  
-===== Creating Docker Image =====+===== Creating ​Minimal Base Docker Image =====
  
   * Use mkimage.sh to create Docker image.<​code>​$ sudo /​usr/​share/​docker.io/​contrib/​mkimage.sh -t ${USER}/​minbase debootstrap --variant=minbase --components=main --include=inetutils-ping,​inetutils-traceroute,​iproute jessie http://​yourrepo/​debian/</​code>​   * Use mkimage.sh to create Docker image.<​code>​$ sudo /​usr/​share/​docker.io/​contrib/​mkimage.sh -t ${USER}/​minbase debootstrap --variant=minbase --components=main --include=inetutils-ping,​inetutils-traceroute,​iproute jessie http://​yourrepo/​debian/</​code>​
-  * Try to run '​echo'​.<​code>​$ sudo docker run -${USER}/​minbase echo "hello citra"</​code>​+  * Try to run '​echo'​:<​code>​$ sudo docker run -it ${USER}/​minbase echo "hello citra"</​code>​or bash shell:<​code>​$ sudo docker run -it ${USER}/​minbase /bin/bash</​code>​
  
-===== Creating Docker ​Container ​===== +===== Creating ​Custom ​Docker ​Image ===== 
-  * First, create a dockerfile for your container.+  * Firstly, create a dockerfile for your container.<​code>​$ vim dockerfile</​code><​code>​FROM stwn/​minbase 
 +MAINTAINER stwn@NOSPAMduniasemu.org
  
 +RUN apt-get update && apt-get install -y \
 +    apt-utils less sudo screen \
 +    openssh-server openssh-client \
 +    asterisk</​code>​
 +  * Build docker container based on the dockerfile.<​code>#​ docker build -t ${USER}/​asterisk:​test0 - < dockerfile</​code>​
 ===== Frequently Used Commands ===== ===== Frequently Used Commands =====
 +  * Restart docker service with systemd:<​code>#​ systemctl restart docker.service</​code>​
   * Show images:<​code>#​ docker images   * Show images:<​code>#​ docker images
 REPOSITORY ​         TAG                 IMAGE ID            CREATED ​            ​VIRTUAL SIZE REPOSITORY ​         TAG                 IMAGE ID            CREATED ​            ​VIRTUAL SIZE
 stwn/​minbase ​       latest ​             d816657c5182 ​       3 minutes ago       123.7 MB stwn/​minbase ​       latest ​             d816657c5182 ​       3 minutes ago       123.7 MB
 scratch ​            ​latest ​             511136ea3c5a ​       22 months ago       0 B</​code>​ scratch ​            ​latest ​             511136ea3c5a ​       22 months ago       0 B</​code>​
-  * Show all running containers: <​code>#​ docker ps -a</​code>​ +  ​* Remove image:<​code>#​ docker rmi [IMAGE ID]</​code>​ 
-  * Remove ​image: <​code>#​ docker ​rmi <​image>​</​code>​+  * Commit change:<​code>#​ docker commit [IMAGE ID] ${USER}/​asterisk:​test1</​code>​ 
 +  ​* Show all running containers:<​code>#​ docker ps -a</​code>​ 
 +  * Remove ​container:<​code>#​ docker ​rm [CONTAINER ID]</​code>​ 
 + 
 +===== Networking in Docker ===== 
 +There is a network interface named docker0 when we run Docker engine. This interface connected as a (virtual Ethernet) bridge to containers inside Docker and configured with private ip address/​network.
  
 
doc/docker.1430767725.txt.gz · Last modified: 2015/05/04 19:28 by stwn · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki