环境:
Centos 8.1
hadoop 3.3.0
1,阿里yum源下载地址
wget https://mirrors.aliyun.com/repo/Centos-8.repo
1,拉取Centos8.1镜像
[root@centos8 build]# docker pull centos:8.1.1911
8.1.1911: Pulling from library/centos
8a29a15cefae: Pull complete
Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700
Status: Downloaded newer image for centos:8.1.1911
docker.io/library/centos:8.1.1911
3,编译Dockerfile文件
vim Dockerfile
FROM centos:8.1.1911
MAINTAINER nedy@live.com
ADD Centos-8.repo /etc/yum.repos.d
ADD jdk1.8.0_65.tar.gz /usr/local
ADD hadoop-3.3.0.tar.gz /usr/local
RUN yum install -y which
ENV JAVA_HOME /usr/local/jdk1.8.0_65
ENV HADOOP_HOME /usr/local/hadoop-3.3.0
ENV PATH $JAVA_HOME/bin:$PATH
4,执行构建hadoop镜像
docker build -t csctbb.com/hadoop:3.3.0 .
[root@centos8 build]# docker build -t csctbb.com/hadoop:3.3.0 .
Sending build context to Docker daemon 692.6MB
Step 1/9 : FROM centos:8.1.1911
---> 470671670cac
Step 2/9 : MAINTAINER nedy@live.com
---> Running in c13dd9b6ad48
Removing intermediate container c13dd9b6ad48
---> 05b718c5d059
Step 3/9 : ADD Centos-8.repo /etc/yum.repos.d
---> 32ab0b34cf19
Step 4/9 : ADD jdk1.8.0_65.tar.gz /usr/local
---> 63bb7200de2a
Step 5/9 : ADD hadoop-3.3.0.tar.gz /usr/local
---> 5bab07fd7b3a
Step 6/9 : RUN yum install -y which
---> Running in 781e3e3cdb9e
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
CentOS-8 - AppStream 2.3 MB/s | 6.3 MB 00:02
CentOS-8 - Base 1.1 MB/s | 2.3 MB 00:02
CentOS-8 - Extras 7.5 kB/s | 9.6 kB 00:01
CentOS-8 - Base - mirrors.aliyun.com 1.8 MB/s | 2.3 MB 00:01
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
which x86_64 2.21-12.el8 BaseOS 49 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 49 k
Installed size: 81 k
Downloading Packages:
which-2.21-12.el8.x86_64.rpm 134 kB/s | 49 kB 00:00
--------------------------------------------------------------------------------
Total 48 kB/s | 49 kB 00:01
warning: /var/cache/dnf/BaseOS-f6a80ba95cf937f2/packages/which-2.21-12.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS-8 - Base 55 kB/s | 1.6 kB 00:00
Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : which-2.21-12.el8.x86_64 1/1
Running scriptlet: which-2.21-12.el8.x86_64 1/1
Verifying : which-2.21-12.el8.x86_64 1/1
Installed:
which-2.21-12.el8.x86_64
Complete!
Removing intermediate container 781e3e3cdb9e
---> ed31949179d7
Step 7/9 : ENV JAVA_HOME /usr/local/jdk1.8.0_65
---> Running in c126c848a4f0
Removing intermediate container c126c848a4f0
---> 3f6d5bbd3743
Step 8/9 : ENV HADOOP_HOME /usr/local/hadoop-3.3.0
---> Running in d2f201ee5f05
Removing intermediate container d2f201ee5f05
---> d7404429f45c
Step 9/9 : ENV PATH $JAVA_HOME/bin:$PATH
---> Running in 0d20932ec238
Removing intermediate container 0d20932ec238
---> 084faab5baec
Successfully built 084faab5baec
Successfully tagged csctbb.com/hadoop:3.3.0
查看镜像列表
root@centos8 build]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
csctbb.com/hadoop 3.3.0 084faab5baec 6 minutes ago 1.68GB
centos 8.1.1911 470671670cac 14 months ago 237MB
kubeguide/hadoop latest e0af06208032 4 years ago 830MB
导出镜像
[root@centos8 ~]# docker save 084faab5baec > csctbb.com-hadoop.tar
导入镜像
docker load -i csctbb.com-hadoop.tar