You need to enable JavaScript to run this app.
导航
在Docker中使用EMR CLI
最近更新时间:2024.10.29 14:10:17首次发布时间:2024.10.29 14:10:17

安装Docker

在ECS节点上启动容器,安装Docker。

  1. 如果您安装过Docker,须先卸载机器上的docker残留,执行如下命令。
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
  1. 安装依赖包。
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
  1. 设置镜像。
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  1. 下载安装docker。
sudo yum install docker-ce
  1. 启动运行。
sudo systemctl enable docker   # 设置开启自启
sudo systemctl start docker    # 启动Docker

启动并运行容器

  1. 使用centos7.9编写dockerFile基础镜像。

注意

开源网站的centos7.9相对于火山引擎上提供的centos镜像缺少一些工具,请使用下面的Dockerfile。

FROM docker.m.daocloud.io/centos:centos7.9.2009

RUN echo "[base]" > /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-7 - Base - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=http://mirrors.aliyun.com/centos/7/os/\$basearch/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[updates]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-7 - Updates - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=http://mirrors.aliyun.com/centos/7/updates/\$basearch/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[extras]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-7 - Extras - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=http://mirrors.aliyun.com/centos/7/extras/\$basearch/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" >> /etc/yum.repos.d/CentOS-Base.repo



RUN yum -y update &&  yum -y groupinstall 'Development Tools' && yum install -y wget vim   openssl-devel
#yum -y install libffi-devel gcc openssl-devel bzip2-devel

RUN yum clean all && yum makecache

WORKDIR /home/work

RUN wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz && tar -xf openssl-1.1.1l.tar.gz && cd openssl-1.1.1l \
    && ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl \
    && make \
    && make install

RUN export LD_LIBRARY_PATH=/usr/local/openssl/lib && export CFLAGS="-I/usr/local/openssl/include" && export LDFLAGS="-L/usr/local/openssl/lib"

# regionId=`curl http://100.96.0.96/latest/region_id`; curl https://emrcli-${regionId}.tos-${regionId}.ivolces.com/emrcli.sh -o emrcli.sh; chmod 755 emrcli.sh;

# ./emrcli.sh install cn-beijing

# docker run -dit emr:latest  tail -f /dev/null
  1. 创建并运行容器。
# 在dockerfile文件所在目录执行
docker build -t liubin-centos7.9:v1
# 运行
docker run -t -i liubin-centos7.9:v1 /bin/bash
  1. 安装EMR CLI。

说明

安装步骤与在ECS上安装EMR CLI 相同。详细操作参考:EMR 集群客户端最佳实践