0%

Before installation

root@pts/0 # uname -r
2.6.32-279.el6.x86_64

For Centos-6.5, the Docker package is part of Extra Packages for Enterprise Linux (EPEL) repository, a community effort to create and maintain additional packages for the RHEL distribution.

Install epel package

root@pts/0 # rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.jZDBGF: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

root@pts/0 # ls -lart /etc/yum.repos.d/
total 32
-rw-r--r--.  1 root root 2593 Jun 26  2012 CentOS-Vault.repo
-rw-r--r--.  1 root root  626 Jun 26  2012 CentOS-Media.repo
-rw-r--r--.  1 root root  637 Jun 26  2012 CentOS-Debuginfo.repo
-rw-r--r--.  1 root root 1926 Jun 26  2012 CentOS-Base.repo
-rw-r--r--   1 root root 1056 Nov  5  2012 epel-testing.repo
-rw-r--r--   1 root root  957 Nov  5  2012 epel.repo

# here you need to modify epel.repo 
before:
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
gpgcheck=1

after change
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
gpgcheck=0

Install docker

yum install docker-io
======================================================================================================================================
 Package                           Arch                      Version                                 Repository                  Size
======================================================================================================================================
Installing:
 docker-io                         x86_64                    1.4.1-3.el6                             epel                       4.5 M
Installing for dependencies:
 libcgroup                         x86_64                    0.40.rc1-15.el6_6                       updates                    129 k
 lua-alt-getopt                    noarch                    0.7.0-1.el6                             epel                       6.9 k
 lua-filesystem                    x86_64                    1.4.2-1.el6                             epel                        24 k
 lua-lxc                           x86_64                    1.0.7-1.el6                             epel                        15 k
 lxc                               x86_64                    1.0.7-1.el6                             epel                       120 k
 lxc-libs                          x86_64                    1.0.7-1.el6                             epel                       249 k

Transaction Summary
======================================================================================================================================
Install       7 Package(s)

Start docker

service docker start
## or you do like this 
/etc/init.d/docker start

## here after you start docker ,and try docker info or docker version, it showed errors 
FATA[0000] Cannot connect to the Docker daemon. Is 'docker -d' running on this host? 
## and find no docker process 
root@pts/0 # ps -ef|grep docker 
root      2216  1351  0 13:12 pts/0    00:00:00 grep docker

fix error

yum install -y device-mapper
======================================================================================================================================
 Package                                   Arch                    Version                             Repository                Size
======================================================================================================================================
Updating:
 device-mapper                             x86_64                  1.02.90-2.el6_6.1                   updates                  173 k
Updating for dependencies:
 device-mapper-event                       x86_64                  1.02.90-2.el6_6.1                   updates                  122 k
 device-mapper-event-libs                  x86_64                  1.02.90-2.el6_6.1                   updates                  116 k
 device-mapper-libs                        x86_64                  1.02.90-2.el6_6.1                   updates                  218 k
 libblkid                                  x86_64                  2.17.2-12.18.el6                    base                     116 k
 libuuid                                   x86_64                  2.17.2-12.18.el6                    base                      69 k
 util-linux-ng                             x86_64                  2.17.2-12.18.el6                    base                     1.6 M

Transaction Summary
======================================================================================================================================
Upgrade       7 Package(s)

check if install docker again

/etc/init.d/docker start 
root@pts/0 # /etc/init.d/docker start
Starting docker:                                       [  OK  ]

root@pts/0 # ps -ef|grep docker 
root      2623     1  5 13:18 pts/0    00:00:00 /usr/bin/docker -d
root      2738  1351  0 13:18 pts/0    00:00:00 grep docker

root@pts/3 # docker version 
Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8/1.4.1
OS/Arch (client): linux/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8/1.4.1

Try to pull images

root@pts/0 # docker pull dockercolin/resin:youyuan 
Pulling repository dockercolin/resin
05cbafe808b6: Pulling dependent layers 
511136ea3c5a: Download complete 
b6718650e87e: Download complete 
493bab5fff45: Download complete 
9dbcac75201e: Download complete 
d21eb06e11c9: Downloading [==========>                                        ] 32.97 MB/164.8 MB 55m36s
d21eb06e11c9: Pulling metadata 

Docker install successfully!


公众号: DailyJobOps DailyJobOps

Docker docker-compose

docker-compose && fig

Installation

curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

or you can install docker-compose by PyPi(Python Package Index)

pip install docker-compose 

Install python pip

Note:
Python 2.5 was supported through v1.3.1, and Python 2.4 was supported through v1.1.
refer to :https://pip.pypa.io/en/stable/

Method 1:
## install pip by yum method under centos
yum install -y python-pip

Method 2:
wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar zvxf 1.5.5.tar.gz 
cd pip-1.5.5
python setpu.py install

## at last , use pip to install software
pip install <software-name>

Usage

## get docker-compose help
docker-compose -h
## get certain command help
docker <command> -h
## start service 
docker run 
##
docker up

Example


公众号: DailyJobOps DailyJobOps

no such file or directory

when build a Dockerfile ,and the file ‘redis.conf’ exists in real , but met such erro

Step 5 : RUN mkdir /usr/local/redis/
---> Running in 5cf73a52953f
---> 3351c41a56b4
Removing intermediate container 5cf73a52953f
Step 6 : COPY /home/dockerdir/Dockerfiles/redis.conf /usr/local/redis/conf/
**INFO[0007] home/dockerdir/Dockerfiles/redis.conf: no such file or directory** 

the reason:

  • if you build using STDIN (docker build - < somefile) , this is no build context ,so COPY can’t be used
  • COPY src dest ,here src just only filename without path ,so the file must exist in current build path ,and the dest must the folder with / or the certain filename

#INFO[0000] stat … not a directory
Step 5 : VOLUME /usr/local/redis/logs /usr/local/redis/var /usr/local/redis/conf
—> Using cache
—> a4ed3fb3bbfa
Step 6 : RUN chown -R redis:redis /usr/local/redis
—> Using cache
—> 338c50fe83bf
Step 7 : WORKDIR /usr/local/redis/conf/
—> Using cache
—> 00cbe70420b7
Step 8 : ADD redis.conf /usr/local/redis/conf
INFO[0000] stat /home/dockerdir/docker/devicemapper/mnt/58234d468c89c1e3877620fc6af37205e411ed86176de987e5336df6de8f9b27/rootfs/usr/local/redis/conf/redis.conf: not a directory

the reason

  • the reason is the same like above ,the ADD or COPY destination must be a folder with / or the certain filename

公众号: DailyJobOps DailyJobOps