# ls -l
total 64240
-rw-r----- 1 root root 1383 Jan 8 13:39 Dockerfile
-rw-r----- 1 root root 65776957 Jan 8 13:40 ubuntu-trusty-core-cloudimg-amd64-root.tar.gz
These 2 files are downloaded from https://hub.docker.com/_/ubuntu/ (14.04)
# cat Dockerfile
FROM scratch
ADD ubuntu-trusty-core-cloudimg-amd64-root.tar.gz /
# a few minor docker-specific tweaks
# see https://github.com/docker/docker/blob/master/contrib/mkimage/debootstrap
RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d \
&& echo 'exit 101' >> /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
\
&& dpkg-divert --local --rename --add /sbin/initctl \
&& cp -a /usr/sbin/policy-rc.d /sbin/initctl \
&& sed -i 's/^exit.*/exit 0/' /sbin/initctl \
\
&& echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup \
\
&& echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean \
&& echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean \
&& echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean \
\
&& echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages \
\
&& echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes
# enable the universe
RUN sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
# overwrite this with 'CMD []' in a dependent Dockerfile
CMD ["/bin/bash"]
---------------------------------
Now build ubuntu from Dockerfile
# docker build /tmp/ubuntu
Sending build context to Docker daemon 65.78 MB
Sending build context to Docker daemon
Step 0 : FROM scratch
--->
Step 1 : ADD ubuntu-trusty-core-cloudimg-amd64-root.tar.gz /
---> 722fff301cf8
Removing intermediate container 3ac8f98d2503
Step 2 : RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d && echo 'exit 101' >> /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && dpkg-divert --local --rename --add /sbin/initctl && cp -a /usr/sbin/policy-rc.d /sbin/initctl && sed -i 's/^exit.*/exit 0/' /sbin/initctl && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes
---> Running in ca06d044f4ea
Adding 'local diversion of /sbin/initctl to /sbin/initctl.distrib'
---> c1007a188518
Removing intermediate container ca06d044f4ea
Step 3 : RUN sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
---> Running in 86a418b9a27f
---> e369918520d5
Removing intermediate container 86a418b9a27f
Step 4 : CMD /bin/bash
---> Running in b4e86758488e
---> 9d4dfcbd71bf
Removing intermediate container b4e86758488e
Successfully built 9d4dfcbd71bf
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 9d4dfcbd71bf 5 minutes ago 187.9 MB
Fedora-Docker-Base-23-20151030.x86_64 latest 79c267013159 10 weeks ago 204.3 MB
# docker tag 9d4dfcbd71bf ubuntu:14.04
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 9d4dfcbd71bf 6 minutes ago 187.9 MB
Fedora-Docker-Base-23-20151030.x86_64 latest 79c267013159 10 weeks ago 204.3 MB
# docker tag 79c267013159 fedora:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 9d4dfcbd71bf 8 minutes ago 187.9 MB
Fedora-Docker-Base-23-20151030.x86_64 latest 79c267013159 10 weeks ago 204.3 MB
fedora latest 79c267013159 10 weeks ago 204.3 MB
# docker rmi Fedora-Docker-Base-23-20151030.x86_64
Untagged: Fedora-Docker-Base-23-20151030.x86_64:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 9d4dfcbd71bf 9 minutes ago 187.9 MB
fedora latest 79c267013159 10 weeks ago 204.3 MB
Showing posts with label Docker. Show all posts
Showing posts with label Docker. Show all posts
Friday, January 8, 2016
Monday, March 30, 2015
Linux : Install docker-io
Red Hat 6.6
Download the following rpm from http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/
docker-io-1.4.1-3.el6.x86_64.rpm
lua-lxc-1.0.7-1.el6.x86_64.rpm
lua-alt-getopt-0.7.0-1.el6.noarch.rpm
lxc-1.0.7-1.el6.x86_64.rpm
lua-filesystem-1.4.2-1.el6.x86_64.rpm
lxc-libs-1.0.7-1.el6.x86_64.rpm
# rpm -Uvh *.rpm
warning: docker-io-1.4.1-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:lxc-libs ########################################### [ 17%]
2:lua-filesystem ########################################### [ 33%]
3:lua-lxc ########################################### [ 50%]
4:lua-alt-getopt ########################################### [ 67%]
5:lxc ########################################### [ 83%]
6:docker-io ########################################### [100%]
# chkconfig --list docker
docker 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# service docker start
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
https://access.redhat.com/articles/881893
http://developerblog.redhat.com/2014/05/15/practical-introduction-to-docker-containers/
Docker has an official CentOS 6 repository which they support:
Download the docker image zip file manually
# cat centos-7-20150304_1234-docker.tar.xz | docker import - centos7:base
f4f6169a4b1175b2ed2f9c9f95369f8eec04b28c41b946280f45205e58bc7c05
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos7 base f4f6169a4b11 14 seconds ago 210 MB
Create docker image from my own system
Download the following rpm from http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/
docker-io-1.4.1-3.el6.x86_64.rpm
lua-lxc-1.0.7-1.el6.x86_64.rpm
lua-alt-getopt-0.7.0-1.el6.noarch.rpm
lxc-1.0.7-1.el6.x86_64.rpm
lua-filesystem-1.4.2-1.el6.x86_64.rpm
lxc-libs-1.0.7-1.el6.x86_64.rpm
# rpm -Uvh *.rpm
warning: docker-io-1.4.1-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:lxc-libs ########################################### [ 17%]
2:lua-filesystem ########################################### [ 33%]
3:lua-lxc ########################################### [ 50%]
4:lua-alt-getopt ########################################### [ 67%]
5:lxc ########################################### [ 83%]
6:docker-io ########################################### [100%]
# chkconfig --list docker
docker 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# service docker start
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
https://access.redhat.com/articles/881893
http://developerblog.redhat.com/2014/05/15/practical-introduction-to-docker-containers/
Docker has an official CentOS 6 repository which they support:
Download the docker image zip file manually
# cat centos-7-20150304_1234-docker.tar.xz | docker import - centos7:base
f4f6169a4b1175b2ed2f9c9f95369f8eec04b28c41b946280f45205e58bc7c05
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos7 base f4f6169a4b11 14 seconds ago 210 MB
Create docker image from my own system
- Create the tar files for your file system, simply could be
tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos6-base.tar / - Transfer the tar file to other docker system if not installed locally and
importit
cat centos6-base.tar | docker import - centos6-base - Now you can verify by running it.
docker run -i -t centos6-base cat /etc/redhat-releasetar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/root \--exclude=/var --exclude=/home --exclude=/docker --exclude=/tmp \-cvf centos6-base.tar /cat centos6-base.tar | docker import - centos6-base 500e53a55f35cb64724a544b6b94d2db9629f9910564a3611ab106b78b7fd62fdocker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos6-base latest 500e53a55f35 53 seconds ago 2.621 GB
Tuesday, July 1, 2014
Install Docker on CentOS 6
Please also refer here
We are going to install Docker from EPEL repository.
Check if the EPEL repository is there :
# rpm -qa | grep epel
epel-release-6-8.noarch
I do have epel on my server. If not, you need to install it.
Now continue to install docker-io
$ sudo yum install docker-io
[sudo] password for lo:
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.cs.vt.edu
* epel: epel.mirror.constant.com
* extras: mirror.anl.gov
* updates: mirrors-pa.sioru.com
222 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.0.0-3.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.0.0-3.el6.x86_64
--> Running transaction check
---> Package lxc.x86_64 0:0.9.0-2.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.9.0-2.el6.x86_64
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.9.0-2.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
docker-io x86_64 1.0.0-3.el6 epel 4.5 M
Installing for dependencies:
lxc x86_64 0.9.0-2.el6 epel 78 k
lxc-libs x86_64 0.9.0-2.el6 epel 116 k
Transaction Summary
====================================================================================================================
Install 3 Package(s)
Total download size: 4.7 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): docker-io-1.0.0-3.el6.x86_64.rpm | 4.5 MB 00:03
(2/3): lxc-0.9.0-2.el6.x86_64.rpm | 78 kB 00:00
(3/3): lxc-libs-0.9.0-2.el6.x86_64.rpm | 116 kB 00:00
--------------------------------------------------------------------------------------------------------------------
Total 1.4 MB/s | 4.7 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lxc-libs-0.9.0-2.el6.x86_64 1/3
Installing : lxc-0.9.0-2.el6.x86_64 2/3
Installing : docker-io-1.0.0-3.el6.x86_64 3/3
Verifying : docker-io-1.0.0-3.el6.x86_64 1/3
Verifying : lxc-libs-0.9.0-2.el6.x86_64 2/3
Verifying : lxc-0.9.0-2.el6.x86_64 3/3
Installed:
docker-io.x86_64 0:1.0.0-3.el6
Dependency Installed:
lxc.x86_64 0:0.9.0-2.el6 lxc-libs.x86_64 0:0.9.0-2.el6
Complete!
Now it is install. We need to start the Docker daemon.
$ sudo service docker start
Starting docker: [ OK ]
If we want Docker to start at boot, we need to run this :
$ sudo chkconfig docker on
Now we try test Docker and get the CentOS image
$ sudo docker pull centos:latest
Pulling repository centos
0c752394b855: Download complete
511136ea3c5a: Download complete
34e94e67e63a: Download complete
We make sure we can see the image :
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 0c752394b855 3 weeks ago 124.1 MB
Now try run bash using this centos image
$ sudo docker run -i -t centos /bin/bash
bash-4.1# ps
PID TTY TIME CMD
1 ? 00:00:00 bash
6 ? 00:00:00 ps
bash-4.1# df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 10321208 300108 9496812 4% /
/dev/mapper/docker-253:0-1179712-6d24d5cf87a18d748db4bc41f1d591f1fa10aebb0e8f3503be0270d9a557d009
10321208 300108 9496812 4% /
tmpfs 3984768 0 3984768 0% /dev
shm 65536 0 65536 0% /dev/shm
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /.dockerinit
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/resolv.conf
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/hostname
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/hosts
tmpfs 3984768 0 3984768 0% /proc/kcore
bash-4.1# pwd
/
bash-4.1# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
Outside of this docker container, we can check what is running :
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d24d5cf87a1 centos:latest /bin/bash 3 minutes ago Up 3 minutes ecstatic_pare
We are going to install Docker from EPEL repository.
Check if the EPEL repository is there :
# rpm -qa | grep epel
epel-release-6-8.noarch
I do have epel on my server. If not, you need to install it.
Now continue to install docker-io
$ sudo yum install docker-io
[sudo] password for lo:
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.cs.vt.edu
* epel: epel.mirror.constant.com
* extras: mirror.anl.gov
* updates: mirrors-pa.sioru.com
222 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.0.0-3.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.0.0-3.el6.x86_64
--> Running transaction check
---> Package lxc.x86_64 0:0.9.0-2.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.9.0-2.el6.x86_64
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.9.0-2.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
docker-io x86_64 1.0.0-3.el6 epel 4.5 M
Installing for dependencies:
lxc x86_64 0.9.0-2.el6 epel 78 k
lxc-libs x86_64 0.9.0-2.el6 epel 116 k
Transaction Summary
====================================================================================================================
Install 3 Package(s)
Total download size: 4.7 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): docker-io-1.0.0-3.el6.x86_64.rpm | 4.5 MB 00:03
(2/3): lxc-0.9.0-2.el6.x86_64.rpm | 78 kB 00:00
(3/3): lxc-libs-0.9.0-2.el6.x86_64.rpm | 116 kB 00:00
--------------------------------------------------------------------------------------------------------------------
Total 1.4 MB/s | 4.7 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lxc-libs-0.9.0-2.el6.x86_64 1/3
Installing : lxc-0.9.0-2.el6.x86_64 2/3
Installing : docker-io-1.0.0-3.el6.x86_64 3/3
Verifying : docker-io-1.0.0-3.el6.x86_64 1/3
Verifying : lxc-libs-0.9.0-2.el6.x86_64 2/3
Verifying : lxc-0.9.0-2.el6.x86_64 3/3
Installed:
docker-io.x86_64 0:1.0.0-3.el6
Dependency Installed:
lxc.x86_64 0:0.9.0-2.el6 lxc-libs.x86_64 0:0.9.0-2.el6
Complete!
Now it is install. We need to start the Docker daemon.
$ sudo service docker start
Starting docker: [ OK ]
If we want Docker to start at boot, we need to run this :
$ sudo chkconfig docker on
Now we try test Docker and get the CentOS image
$ sudo docker pull centos:latest
Pulling repository centos
0c752394b855: Download complete
511136ea3c5a: Download complete
34e94e67e63a: Download complete
We make sure we can see the image :
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 0c752394b855 3 weeks ago 124.1 MB
Now try run bash using this centos image
$ sudo docker run -i -t centos /bin/bash
bash-4.1# ps
PID TTY TIME CMD
1 ? 00:00:00 bash
6 ? 00:00:00 ps
bash-4.1# df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 10321208 300108 9496812 4% /
/dev/mapper/docker-253:0-1179712-6d24d5cf87a18d748db4bc41f1d591f1fa10aebb0e8f3503be0270d9a557d009
10321208 300108 9496812 4% /
tmpfs 3984768 0 3984768 0% /dev
shm 65536 0 65536 0% /dev/shm
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /.dockerinit
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/resolv.conf
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/hostname
/dev/mapper/vg_novo-lv_root
407481848 84566084 302216836 22% /etc/hosts
tmpfs 3984768 0 3984768 0% /proc/kcore
bash-4.1# pwd
/
bash-4.1# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
Outside of this docker container, we can check what is running :
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d24d5cf87a1 centos:latest /bin/bash 3 minutes ago Up 3 minutes ecstatic_pare
Subscribe to:
Posts (Atom)