Docker on Debian

Prerequisites

  • Packages installed: debootstrap and friends.
  • I use Debian testing/jessie (now stable), and put sid into sources.list so I can apt-get install docker.io, because docker.io removed from testing in late March 2015 and available only in sid.
    # vim /etc/apt/sources.list
    deb http://yourrepo/debian/ sid main
  • Update your packages list.
    # apt-get update
  • Install docker.io with:
    # apt-get install docker.io

Creating Minimal Base Docker Image

  • Use mkimage.sh to create Docker image.
    $ 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/
  • Try to run 'echo':
    $ sudo docker run -it ${USER}/minbase echo "hello citra"

    or bash shell:

    $ sudo docker run -it ${USER}/minbase /bin/bash

Creating Custom Docker Image

  • Firstly, create a dockerfile for your container.
    $ vim dockerfile
    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
  • Build docker container based on the dockerfile.
    # docker build -t ${USER}/asterisk:test0 - < dockerfile

Frequently Used Commands

  • Restart docker service with systemd:
    # systemctl restart docker.service
  • Show images:
    # docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    stwn/minbase        latest              d816657c5182        3 minutes ago       123.7 MB
    scratch             latest              511136ea3c5a        22 months ago       0 B
  • Remove image:
    # docker rmi [IMAGE ID]
  • Commit change:
    # docker commit [IMAGE ID] ${USER}/asterisk:test1
  • Show all running containers:
    # docker ps -a
  • Remove container:
    # docker rm [CONTAINER ID]

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.txt · Last modified: 2015/05/08 10:41 by stwn · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki