Skip to content

Instantly share code, notes, and snippets.

@KEINOS
Last active May 3, 2019 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KEINOS/31a2cba4f65f58f84d9f6b0873de81dd to your computer and use it in GitHub Desktop.
Save KEINOS/31a2cba4f65f58f84d9f6b0873de81dd to your computer and use it in GitHub Desktop.
[LOG] Sample of building CentOS docker image with Dockerfile. See: https://qiita.com/KEINOS/items/518610bc2fdf5999acf2#comment-a773ef2493ab505fce95
$ # Env infos
$ # ---------
$ docker version
Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:43 2018
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:55:00 2018
OS/Arch: linux/amd64
Experimental: false
$ # Directory structure
$ tree
.
└── Dockerfile
0 directories, 1 file
$
$ # Contents of the Dockerfile
$ cat Dockerfile
FROM centos:latest
RUN yum update -y && \
yum install -y \
gcc \
glibc
$
$ # Build
$ # -----
$ # Build image with the name as 'my_centos_image'
$ docker build --tag my_centos_image .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM centos:latest
---> 9f38484d220f
Step 2/2 : RUN yum update -y && yum install -y gcc glibc
---> Running in 61d6c84a02c2
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package dbus.x86_64 1:1.10.24-12.el7 will be updated
---> Package dbus.x86_64 1:1.10.24-13.el7_6 will be an update
---> Package dbus-libs.x86_64 1:1.10.24-12.el7 will be updated
---> Package dbus-libs.x86_64 1:1.10.24-13.el7_6 will be an update
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.3 will be updated
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.7 will be an update
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.7 will be an update
---> Package glibc.x86_64 0:2.17-260.el7_6.3 will be updated
---> Package glibc.x86_64 0:2.17-260.el7_6.4 will be an update
---> Package glibc-common.x86_64 0:2.17-260.el7_6.3 will be updated
---> Package glibc-common.x86_64 0:2.17-260.el7_6.4 will be an update
---> Package libblkid.x86_64 0:2.23.2-59.el7 will be updated
---> Package libblkid.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libmount.x86_64 0:2.23.2-59.el7 will be updated
---> Package libmount.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libsmartcols.x86_64 0:2.23.2-59.el7 will be updated
---> Package libsmartcols.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libssh2.x86_64 0:1.4.3-12.el7 will be updated
---> Package libssh2.x86_64 0:1.4.3-12.el7_6.2 will be an update
---> Package libstdc++.x86_64 0:4.8.5-36.el7 will be updated
---> Package libstdc++.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libuuid.x86_64 0:2.23.2-59.el7 will be updated
---> Package libuuid.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package nss-pem.x86_64 0:1.0.3-5.el7 will be updated
---> Package nss-pem.x86_64 0:1.0.3-5.el7_6.1 will be an update
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7 will be updated
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
---> Package python.x86_64 0:2.7.5-76.el7 will be updated
---> Package python.x86_64 0:2.7.5-77.el7_6 will be an update
---> Package python-libs.x86_64 0:2.7.5-76.el7 will be updated
---> Package python-libs.x86_64 0:2.7.5-77.el7_6 will be an update
---> Package shadow-utils.x86_64 2:4.1.5.1-25.el7 will be updated
---> Package shadow-utils.x86_64 2:4.1.5.1-25.el7_6.1 will be an update
---> Package systemd.x86_64 0:219-62.el7_6.5 will be updated
---> Package systemd.x86_64 0:219-62.el7_6.6 will be an update
---> Package systemd-libs.x86_64 0:219-62.el7_6.5 will be updated
---> Package systemd-libs.x86_64 0:219-62.el7_6.6 will be an update
---> Package tzdata.noarch 0:2018i-1.el7 will be updated
---> Package tzdata.noarch 0:2019a-1.el7 will be an update
---> Package util-linux.x86_64 0:2.23.2-59.el7 will be updated
---> Package util-linux.x86_64 0:2.23.2-59.el7_6.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
dbus x86_64 1:1.10.24-13.el7_6 updates 245 k
dbus-libs x86_64 1:1.10.24-13.el7_6 updates 169 k
device-mapper x86_64 7:1.02.149-10.el7_6.7 updates 293 k
device-mapper-libs x86_64 7:1.02.149-10.el7_6.7 updates 320 k
glibc x86_64 2.17-260.el7_6.4 updates 3.7 M
glibc-common x86_64 2.17-260.el7_6.4 updates 12 M
libblkid x86_64 2.23.2-59.el7_6.1 updates 181 k
libgcc x86_64 4.8.5-36.el7_6.2 updates 102 k
libmount x86_64 2.23.2-59.el7_6.1 updates 182 k
libsmartcols x86_64 2.23.2-59.el7_6.1 updates 140 k
libssh2 x86_64 1.4.3-12.el7_6.2 updates 135 k
libstdc++ x86_64 4.8.5-36.el7_6.2 updates 305 k
libuuid x86_64 2.23.2-59.el7_6.1 updates 82 k
nss-pem x86_64 1.0.3-5.el7_6.1 updates 74 k
openssl-libs x86_64 1:1.0.2k-16.el7_6.1 updates 1.2 M
python x86_64 2.7.5-77.el7_6 updates 94 k
python-libs x86_64 2.7.5-77.el7_6 updates 5.6 M
shadow-utils x86_64 2:4.1.5.1-25.el7_6.1 updates 1.1 M
systemd x86_64 219-62.el7_6.6 updates 5.1 M
systemd-libs x86_64 219-62.el7_6.6 updates 407 k
tzdata noarch 2019a-1.el7 updates 494 k
util-linux x86_64 2.23.2-59.el7_6.1 updates 2.0 M
Transaction Summary
================================================================================
Upgrade 22 Packages
Total download size: 33 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/updates/packages/dbus-libs-1.10.24-13.el7_6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for dbus-libs-1.10.24-13.el7_6.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total 8.5 MB/s | 33 MB 00:03
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libgcc-4.8.5-36.el7_6.2.x86_64 1/44
Updating : tzdata-2019a-1.el7.noarch 2/44
Updating : glibc-common-2.17-260.el7_6.4.x86_64 3/44
Updating : glibc-2.17-260.el7_6.4.x86_64 4/44
Updating : systemd-libs-219-62.el7_6.6.x86_64 5/44
Updating : libuuid-2.23.2-59.el7_6.1.x86_64 6/44
Updating : libblkid-2.23.2-59.el7_6.1.x86_64 7/44
Updating : libmount-2.23.2-59.el7_6.1.x86_64 8/44
Updating : 2:shadow-utils-4.1.5.1-25.el7_6.1.x86_64 9/44
Updating : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 10/44
Updating : python-libs-2.7.5-77.el7_6.x86_64 11/44
Updating : 1:dbus-libs-1.10.24-13.el7_6.x86_64 12/44
Updating : systemd-219-62.el7_6.6.x86_64 13/44
Failed to get D-Bus connection: Operation not permitted
Updating : 1:dbus-1.10.24-13.el7_6.x86_64 14/44
Updating : libsmartcols-2.23.2-59.el7_6.1.x86_64 15/44
Updating : util-linux-2.23.2-59.el7_6.1.x86_64 16/44
Updating : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64 17/44
Updating : 7:device-mapper-1.02.149-10.el7_6.7.x86_64 18/44
Updating : python-2.7.5-77.el7_6.x86_64 19/44
Updating : libssh2-1.4.3-12.el7_6.2.x86_64 20/44
Updating : nss-pem-1.0.3-5.el7_6.1.x86_64 21/44
Updating : libstdc++-4.8.5-36.el7_6.2.x86_64 22/44
Cleanup : 7:device-mapper-1.02.149-10.el7_6.3.x86_64 23/44
Cleanup : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64 24/44
Cleanup : 1:dbus-1.10.24-12.el7.x86_64 25/44
Cleanup : systemd-219-62.el7_6.5.x86_64 26/44
Cleanup : util-linux-2.23.2-59.el7.x86_64 27/44
Cleanup : libmount-2.23.2-59.el7.x86_64 28/44
Cleanup : python-2.7.5-76.el7.x86_64 29/44
Cleanup : python-libs-2.7.5-76.el7.x86_64 30/44
Cleanup : libblkid-2.23.2-59.el7.x86_64 31/44
Cleanup : 1:dbus-libs-1.10.24-12.el7.x86_64 32/44
Cleanup : systemd-libs-219-62.el7_6.5.x86_64 33/44
Cleanup : libssh2-1.4.3-12.el7.x86_64 34/44
Cleanup : libstdc++-4.8.5-36.el7.x86_64 35/44
Cleanup : 1:openssl-libs-1.0.2k-16.el7.x86_64 36/44
Cleanup : libuuid-2.23.2-59.el7.x86_64 37/44
Cleanup : libsmartcols-2.23.2-59.el7.x86_64 38/44
Cleanup : 2:shadow-utils-4.1.5.1-25.el7.x86_64 39/44
Cleanup : nss-pem-1.0.3-5.el7.x86_64 40/44
Cleanup : glibc-common-2.17-260.el7_6.3.x86_64 41/44
Cleanup : glibc-2.17-260.el7_6.3.x86_64 42/44
Cleanup : tzdata-2018i-1.el7.noarch 43/44
Cleanup : libgcc-4.8.5-36.el7.x86_64 44/44
Verifying : nss-pem-1.0.3-5.el7_6.1.x86_64 1/44
Verifying : libblkid-2.23.2-59.el7_6.1.x86_64 2/44
Verifying : util-linux-2.23.2-59.el7_6.1.x86_64 3/44
Verifying : libmount-2.23.2-59.el7_6.1.x86_64 4/44
Verifying : python-libs-2.7.5-77.el7_6.x86_64 5/44
Verifying : libstdc++-4.8.5-36.el7_6.2.x86_64 6/44
Verifying : 2:shadow-utils-4.1.5.1-25.el7_6.1.x86_64 7/44
Verifying : libssh2-1.4.3-12.el7_6.2.x86_64 8/44
Verifying : libgcc-4.8.5-36.el7_6.2.x86_64 9/44
Verifying : tzdata-2019a-1.el7.noarch 10/44
Verifying : 1:dbus-libs-1.10.24-13.el7_6.x86_64 11/44
Verifying : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64 12/44
Verifying : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 13/44
Verifying : python-2.7.5-77.el7_6.x86_64 14/44
Verifying : libsmartcols-2.23.2-59.el7_6.1.x86_64 15/44
Verifying : 1:dbus-1.10.24-13.el7_6.x86_64 16/44
Verifying : libuuid-2.23.2-59.el7_6.1.x86_64 17/44
Verifying : glibc-common-2.17-260.el7_6.4.x86_64 18/44
Verifying : glibc-2.17-260.el7_6.4.x86_64 19/44
Verifying : systemd-libs-219-62.el7_6.6.x86_64 20/44
Verifying : systemd-219-62.el7_6.6.x86_64 21/44
Verifying : 7:device-mapper-1.02.149-10.el7_6.7.x86_64 22/44
Verifying : python-2.7.5-76.el7.x86_64 23/44
Verifying : libblkid-2.23.2-59.el7.x86_64 24/44
Verifying : 1:dbus-1.10.24-12.el7.x86_64 25/44
Verifying : libgcc-4.8.5-36.el7.x86_64 26/44
Verifying : libstdc++-4.8.5-36.el7.x86_64 27/44
Verifying : 1:openssl-libs-1.0.2k-16.el7.x86_64 28/44
Verifying : glibc-2.17-260.el7_6.3.x86_64 29/44
Verifying : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64 30/44
Verifying : libuuid-2.23.2-59.el7.x86_64 31/44
Verifying : nss-pem-1.0.3-5.el7.x86_64 32/44
Verifying : libssh2-1.4.3-12.el7.x86_64 33/44
Verifying : systemd-libs-219-62.el7_6.5.x86_64 34/44
Verifying : 1:dbus-libs-1.10.24-12.el7.x86_64 35/44
Verifying : systemd-219-62.el7_6.5.x86_64 36/44
Verifying : 2:shadow-utils-4.1.5.1-25.el7.x86_64 37/44
Verifying : libmount-2.23.2-59.el7.x86_64 38/44
Verifying : util-linux-2.23.2-59.el7.x86_64 39/44
Verifying : libsmartcols-2.23.2-59.el7.x86_64 40/44
Verifying : python-libs-2.7.5-76.el7.x86_64 41/44
Verifying : tzdata-2018i-1.el7.noarch 42/44
Verifying : glibc-common-2.17-260.el7_6.3.x86_64 43/44
Verifying : 7:device-mapper-1.02.149-10.el7_6.3.x86_64 44/44
Updated:
dbus.x86_64 1:1.10.24-13.el7_6
dbus-libs.x86_64 1:1.10.24-13.el7_6
device-mapper.x86_64 7:1.02.149-10.el7_6.7
device-mapper-libs.x86_64 7:1.02.149-10.el7_6.7
glibc.x86_64 0:2.17-260.el7_6.4
glibc-common.x86_64 0:2.17-260.el7_6.4
libblkid.x86_64 0:2.23.2-59.el7_6.1
libgcc.x86_64 0:4.8.5-36.el7_6.2
libmount.x86_64 0:2.23.2-59.el7_6.1
libsmartcols.x86_64 0:2.23.2-59.el7_6.1
libssh2.x86_64 0:1.4.3-12.el7_6.2
libstdc++.x86_64 0:4.8.5-36.el7_6.2
libuuid.x86_64 0:2.23.2-59.el7_6.1
nss-pem.x86_64 0:1.0.3-5.el7_6.1
openssl-libs.x86_64 1:1.0.2k-16.el7_6.1
python.x86_64 0:2.7.5-77.el7_6
python-libs.x86_64 0:2.7.5-77.el7_6
shadow-utils.x86_64 2:4.1.5.1-25.el7_6.1
systemd.x86_64 0:219-62.el7_6.6
systemd-libs.x86_64 0:219-62.el7_6.6
tzdata.noarch 0:2019a-1.el7
util-linux.x86_64 0:2.23.2-59.el7_6.1
Complete!
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Package glibc-2.17-260.el7_6.4.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-36.el7_6.2 will be installed
--> Processing Dependency: libgomp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: cpp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-36.el7_6.2 will be installed
---> Package glibc-devel.x86_64 0:2.17-260.el7_6.4 will be installed
--> Processing Dependency: glibc-headers = 2.17-260.el7_6.4 for package: glibc-devel-2.17-260.el7_6.4.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-260.el7_6.4.x86_64
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be installed
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.17-260.el7_6.4 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-260.el7_6.4.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-260.el7_6.4.x86_64
--> Running transaction check
---> Package kernel-headers.x86_64 0:3.10.0-957.12.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc x86_64 4.8.5-36.el7_6.2 updates 16 M
Installing for dependencies:
cpp x86_64 4.8.5-36.el7_6.2 updates 5.9 M
glibc-devel x86_64 2.17-260.el7_6.4 updates 1.1 M
glibc-headers x86_64 2.17-260.el7_6.4 updates 683 k
kernel-headers x86_64 3.10.0-957.12.1.el7 updates 8.0 M
libgomp x86_64 4.8.5-36.el7_6.2 updates 158 k
libmpc x86_64 1.0.1-3.el7 base 51 k
mpfr x86_64 3.1.1-4.el7 base 203 k
Transaction Summary
================================================================================
Install 1 Package (+7 Dependent packages)
Total download size: 32 M
Installed size: 60 M
Downloading packages:
--------------------------------------------------------------------------------
Total 8.2 MB/s | 32 MB 00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mpfr-3.1.1-4.el7.x86_64 1/8
Installing : libmpc-1.0.1-3.el7.x86_64 2/8
Installing : cpp-4.8.5-36.el7_6.2.x86_64 3/8
Installing : kernel-headers-3.10.0-957.12.1.el7.x86_64 4/8
Installing : glibc-headers-2.17-260.el7_6.4.x86_64 5/8
Installing : glibc-devel-2.17-260.el7_6.4.x86_64 6/8
Installing : libgomp-4.8.5-36.el7_6.2.x86_64 7/8
Installing : gcc-4.8.5-36.el7_6.2.x86_64 8/8
Verifying : glibc-devel-2.17-260.el7_6.4.x86_64 1/8
Verifying : glibc-headers-2.17-260.el7_6.4.x86_64 2/8
Verifying : mpfr-3.1.1-4.el7.x86_64 3/8
Verifying : libgomp-4.8.5-36.el7_6.2.x86_64 4/8
Verifying : libmpc-1.0.1-3.el7.x86_64 5/8
Verifying : cpp-4.8.5-36.el7_6.2.x86_64 6/8
Verifying : gcc-4.8.5-36.el7_6.2.x86_64 7/8
Verifying : kernel-headers-3.10.0-957.12.1.el7.x86_64 8/8
Installed:
gcc.x86_64 0:4.8.5-36.el7_6.2
Dependency Installed:
cpp.x86_64 0:4.8.5-36.el7_6.2
glibc-devel.x86_64 0:2.17-260.el7_6.4
glibc-headers.x86_64 0:2.17-260.el7_6.4
kernel-headers.x86_64 0:3.10.0-957.12.1.el7
libgomp.x86_64 0:4.8.5-36.el7_6.2
libmpc.x86_64 0:1.0.1-3.el7
mpfr.x86_64 0:3.1.1-4.el7
Complete!
Removing intermediate container 61d6c84a02c2
---> ea44b2269647
Successfully built ea44b2269647
Successfully tagged my_centos_image:latest
$
$ # Test (Create container from the image made)
$ # -------------------------------------------
$ # Create a container from the image newly built.
$ # Then tty interactively to it and see if the gcc
$ # and glibc are installed. Alse remove (--rm) the
$ # container after exit.
$ docker run \
> --rm \
> --tty \
> --interactive \
> --name my_centos_container \
> my_centos_image \
> /bin/bash
[root@f479d80b701f /]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
[root@f479d80b701f /]#
[root@f479d80b701f /]# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
[root@f479d80b701f /]# exit
exit
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment