This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
doc:docker [2015/05/04 19:39] stwn [Creating Docker Container] dockerfile |
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 -i ${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 ===== |
| - | * Firstly, create a dockerfile for your container.<code>FROM stwn/minbase | + | * Firstly, create a dockerfile for your container.<code>$ vim dockerfile</code><code>FROM stwn/minbase |
| MAINTAINER stwn@NOSPAMduniasemu.org | MAINTAINER stwn@NOSPAMduniasemu.org | ||
| Line 20: | Line 20: | ||
| openssh-server openssh-client \ | openssh-server openssh-client \ | ||
| asterisk</code> | 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. | ||