Docker Deep Dive

Creating Our First Image

which version

root@giuseppe-HP-EliteDesk-800-G1-SFF:~# docker version 
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.2.1
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.2.1
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64

root@giuseppe-HP-EliteDesk-800-G1-SFF:~# docker info 
Containers: 5
Images: 39
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 50
 Dirperm1 Supported: false
Execution Driver: native-0.2
Kernel Version: 3.13.0-77-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 8
Total Memory: 11.64 GiB
Name: giuseppe-HP-EliteDesk-800-G1-SFF
WARNING: No swap limit support

inspect using

docker inspect mysql
    "Architecture": "amd64",
    "Author": "",
    "Comment": "",
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [

login inside the docker ubuntu

docker run -i -t ubuntu /bin/bash

you can act like you are in a different machine, because you are in a container

see container stars

 docker search sinatra
NAME                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
erikap/ruby-sinatra                    Docker for hosting Sinatra apps                 3                    [OK]
lucymhdavies/sinatra-boilerplate       Docker image with my boilerplate for Sinat...   1                    [OK]
semtech/mu-sinatra-template            Template for running Sinatra microservices      1                    [OK]
tdiary/rpaproxy-sinatra                                                                1                    [OK]
shaoheshan/sinatra                                                                     0                    [OK]
sashaegorov/docker-alpine-sinatra      Alpine Sinatra is project for running a Si...   0                    [OK]
kerona/sinatra                                                                         0                    [OK]
zoomix/sinatra-galleria                                                                0                    [OK]
torico/sinatra-async                   port 3001. for AWS                              0                    [OK]
shangaijun/sinatra                                                                     0                    [OK]
windurst/sinatra                                                                       0                    [OK]

add a new image to the repository

find a starting images

docker ps -a
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS                      PORTS               NAMES
e161cf2f8d56        training/sinatra:latest   "/bin/bash"            5 minutes ago       Up 5 minutes                                    lonely_turing

get into and modify

 docker run -i -t training/sinatra /bin/bash
root@e161cf2f8d56:/# gem install json
Fetching: json-1.8.3.gem (100%)
Building native extensions.  This could take a while...

commit a new image

 docker commit -m='addedd a ruby json module using gem' -a="Linux academy" e161cf2f8d56 linuxacademy/sinatraimage:v1.1
root@giuseppe-HP-EliteDesk-800-G1-SFF:~# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
linuxacademy/sinatraimage   v1.1                ca311fcb6cd2        8 seconds ago       452.4 MB
ubuntu                      latest              8693db7e8a00        3 weeks ago         187.9 MB
mysql                       latest              7fb43e0ace3a        3 weeks ago         235.2 MB
mysql                       5.5                 699c0769b628        3 weeks ago         131.3 MB
<none>                      <none>              cb6fb082434e        4 weeks ago         125.1 MB
centos                      latest              60e65a8e4030        6 weeks ago         196.6 MB
leanlabs/kanban             1.4.0               3aa71e425069        3 months ago        10.75 MB
leanlabs/redis              1.0.0               33cdfa50babf        8 months ago        6.024 MB
training/sinatra            latest              f0f4ab557f95        20 months ago       447 MB

use a Dockerfile

a Dockerfile is only a set of instruction to build our container

root@giuseppe-HP-EliteDesk-800-G1-SFF:~# mkdir docker
root@giuseppe-HP-EliteDesk-800-G1-SFF:~# cd docker
root@giuseppe-HP-EliteDesk-800-G1-SFF:~/docker# touch Dockerfile
root@giuseppe-HP-EliteDesk-800-G1-SFF:~/docker# vim Dockerfile 
root@giuseppe-HP-EliteDesk-800-G1-SFF:~/docker# cat Dockerfile 
#this is our custom dockerfile build for sharing

# the starting image
FROM ubuntu:latest
MAINTAINER Linux Academy <>
RUN apt-get update
RUN apt-get install -y ruby ruby-dev
root@giuseppe-HP-EliteDesk-800-G1-SFF:~/docker# docker build -t="ubuntu:latest" .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon 
Step 0 : FROM ubuntu:latest
 ---> 8693db7e8a00
Step 1 : MAINTAINER Linux Academy <>
 ---> Running in cd3f17d10b4c
 ---> f3db0bb6da4d
Removing intermediate container cd3f17d10b4c
Step 2 : RUN apt-get update
 ---> Running in 0811fa40aff4
Ign trusty InRelease
Get:1 trusty-updates InRelease [65.9 kB]
Get:2 trusty-security InRelease [65.9 kB]
Hit trusty Release.gpg
Get:3 trusty-updates/main Sources [313 kB]
Get:4 trusty-updates/restricted Sources [5219 B]
Get:5 trusty-updates/universe Sources [186 kB]
Get:6 trusty-updates/main amd64 Packages [875 kB]
Get:7 trusty-updates/restricted amd64 Packages [23.5 kB]
Get:8 trusty-updates/universe amd64 Packages [436 kB]
Get:9 trusty-security/main Sources [129 kB]
Get:10 trusty-security/restricted Sources [3920 B]
Get:11 trusty-security/universe Sources [37.9 kB]
Get:12 trusty-security/main amd64 Packages [517 kB]
Get:13 trusty-security/restricted amd64 Packages [20.2 kB]
Get:14 trusty-security/universe amd64 Packages [160 kB]
Hit trusty Release

this will replace our original ubuntu:latest
Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License