Docker.io Howto

From Cactus Howto
Jump to navigationJump to search

Basics

A running instance of an image is called container. You can make changes to a container (e.g. delete a file), but these changes will not affect the image. However, you can create a new image from a running container (and all it changes) using docker commit <container-id> <image-name>.

Setup

sample docker running under Ubuntu 14.04.1:

itsecorg@pbuilder:~$ sudo aptitude install docker.io

Set proxy for docker:

itsecorg@pbuilder:~$ grep http_proxy /etc/default/docker.io
export http_proxy="http://proxy.int.cactus.de:8080/"
sudo service docker.io restart

Image and Container Handling

Search images

sudo docker search -s 4 "ubuntu"
NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                                   Official Ubuntu base image                      934       [OK]
dockerfile/ubuntu                        Trusted automated Ubuntu (http://www.ubunt...   32                   [OK]
crashsystems/gitlab-docker               A trusted, regularly updated build of GitL...   21                   [OK]
ansible/ubuntu14.04-ansible              Ubuntu 14.04 LTS with ansible                   21                   [OK]
clue/ttrss                               The Tiny Tiny RSS feed reader allows you t...   19                   [OK]
mbentley/ubuntu-django-uwsgi-nginx                                                       17                   [OK]
sylvainlasnier/memcached                 Memcached docker images based on Ubuntu 14...   17                   [OK]
ubuntu-upstart                           Upstart is an event-based replacement for ...   16        [OK]
dockerfile/ubuntu-desktop                Trusted automated Ubuntu Desktop (LXDE) (h...   14                   [OK]
tutum/ubuntu                             Ubuntu image with SSH access. For the root...   13                   [OK]
tinyerp/ubuntu-openerp                   Run OpenERP on Ubuntu - September 2014          10
itsecorg@pbuilder:~$

Install / list / remove images

sudo docker pull ubuntu

Display installed images:

itsecorg@pbuilder:~$ sudo docker images ubuntu
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              utopic              277eb4304907        3 weeks ago         228.5 MB
ubuntu              14.10               277eb4304907        3 weeks ago         228.5 MB
ubuntu              14.04               5506de2b643b        3 weeks ago         199.3 MB
ubuntu              14.04.1             5506de2b643b        3 weeks ago         199.3 MB
ubuntu              latest              5506de2b643b        3 weeks ago         199.3 MB
ubuntu              trusty              5506de2b643b        3 weeks ago         199.3 MB
ubuntu              12.04               0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              12.04.5             0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              precise             0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              12.10               c5881f11ded9        4 months ago        172.2 MB
ubuntu              quantal             c5881f11ded9        4 months ago        172.2 MB
ubuntu              13.04               463ff6be4238        4 months ago        169.4 MB
ubuntu              raring              463ff6be4238        4 months ago        169.4 MB
ubuntu              13.10               195eb90b5349        4 months ago        184.7 MB
ubuntu              saucy               195eb90b5349        4 months ago        184.7 MB
ubuntu              10.04               3db9c44f4520        6 months ago        183 MB
ubuntu              lucid               3db9c44f4520        6 months ago        183 MB
itsecorg@pbuilder:~$

Remove

Remove Container

itsecorg@pbuilder:~$ sudo docker rm busybox

Remove Image(s)

itsecorg@pbuilder:~$ sudo docker rmi 0b310e6bf058 c5881f11ded9  463ff6be4238 195eb90b5349 3db9c44f4520


Better:

sudo docker pull ubuntu:14.04.1
itsecorg@pbuilder:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              14.04.1             5506de2b643b        3 weeks ago         199.3 MB
itsecorg@pbuilder:~$

Show containers

itsecorg@pbuilder:~$ sudo docker ps -a --no-trunc=true
itsecorg@pbuilder:~$ sudo docker ps -a --no-trunc=false
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                           PORTS               NAMES
09a4d97bdc2b        ubuntu:14.04.1      sudo http_proxy=http   About an hour ago   Exited (0) About an hour ago                         loving_hypatia
b4360f35202b        ubuntu:14.04.1      sudo http_proxy=http   About an hour ago   Exited (0) About an hour ago                         cocky_perlman
8d1fbf98c719        ubuntu:14.04.1      sudo http_proxy=http   About an hour ago   Exited (0) About an hour ago                         backstabbing_newton

Create new image from container

Syntax:

sudo docker commit <container-id> <image-name>

Example:

sudo docker commit b4360f35202b ubuntu-new