# 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
No comments:
Post a Comment