这是我的 Dockerfile:
FROM centos:6.6
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo ZONE=\"Asia/Shanghai\" > /etc/sysconfig/clock
RUN rm -rf /etc/yum.repos.d/*.repo
#COPY CentOS6-Base-163.repo /etc/yum.repos.d/
RUN yum clean all
RUN groupadd -g 2500 canal; useradd -u 2501 -g canal -d /home/canal -m canal
RUN echo canal:De@2018er | chpasswd; echo root:dockerroot | chpasswd
RUN yum -y update && yum -y install wget vi openssl.x86_64 glibc.x86_64 tar tar.x86_64 inetutils-ping net-tools telnet which file
RUN yum clean all
COPY jdk-8u291-linux-x64.tar.gz /opt
RUN tar -zvxf /opt/jdk-8u291-linux-x64.tar.gz -C /opt && \
rm -rf /opt/jdk-8u291-linux-x64.tar.gz && \
chmod -R 755 /opt/jdk1.8.0_291 && \
chown -R root:root /opt/jdk1.8.0_291
RUN echo 'export JAVA_HOME=/opt/jdk1.8.0_291' >> /etc/profile
RUN echo 'export JRE_HOME=$JAVA_HOME/jre' >> /etc/profile
RUN echo 'export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH' >> /etc/profile
RUN echo 'export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >> /etc/profile
RUN source /etc/profile
RUN yum install kde-l10n-Chinese -y
RUN yum install glibc-common -y
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
ENV JAVA_HOME /opt/jdk1.8.0_291
ENV PATH $PATH:$JAVA_HOME/bin
ENV LANG zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8
ADD canal-server /home/canal/
RUN chmod 755 /home/canal/bin
WORKDIR /home/canal/bin
RUN chmod 777 /home/canal/bin/restart.sh
RUN chmod 777 /home/canal/bin/startup.sh
RUN chmod 777 /home/canal/bin/stop.sh
RUN chmod 777 /home/canal/bin/config.sh
CMD /home/canal/bin/config.sh
当我使用此命令构建 docker 映像时:
docker build -t canal/canal-server:v1.1.5 .
显示此错误:
~/Software/canal-server ⌚ 15:31:31
$ docker build -t canal/canal-server:v1.1.5 . ‹ruby-3.0.0›
[+] Building 4.3s (15/30)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.87kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:6.6 1.3s
=> [ 1/26] FROM docker.io/library/centos:6.6@sha256:32b80b90ba17ed16e9fa3430a49f53ff6de0d4c76ad8631717a1373d5921fa26 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 6.60kB 0.0s
=> CACHED [ 2/26] RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 0.0s
=> CACHED [ 3/26] RUN echo ZONE="Asia/Shanghai" > /etc/sysconfig/clock 0.0s
=> CACHED [ 4/26] RUN rm -rf /etc/yum.repos.d/*.repo 0.0s
=> CACHED [ 5/26] RUN yum clean all 0.0s
=> CACHED [ 6/26] RUN groupadd -g 2500 canal; useradd -u 2501 -g canal -d /home/canal -m canal 0.0s
=> CACHED [ 7/26] RUN echo canal:De@2018er | chpasswd; echo root:dockerroot | chpasswd 0.0s
=> [ 8/26] RUN yum -y update && yum -y install wget vi openssl.x86_64 glibc.x86_64 tar tar.x86_64 inetutils-ping net-tools telnet which file 0.7s
=> [ 9/26] RUN yum clean all 0.4s
=> [10/26] COPY jdk-8u291-linux-x64.tar.gz /opt 1.2s
=> ERROR [11/26] RUN tar -zvxf /opt/jdk-8u291-linux-x64.tar.gz -C /opt && rm -rf /opt/jdk-8u291-linux-x64.tar.gz && chmod -R 755 /opt/jdk1.8.0_291 && 0.5s
------
> [11/26] RUN tar -zvxf /opt/jdk-8u291-linux-x64.tar.gz -C /opt && rm -rf /opt/jdk-8u291-linux-x64.tar.gz && chmod -R 755 /opt/jdk1.8.0_291 && chown -R root:root /opt/jdk1.8.0_291:
#15 0.489 /bin/sh: tar: command not found
------
executor failed running [/bin/sh -c tar -zvxf /opt/jdk-8u291-linux-x64.tar.gz -C /opt && rm -rf /opt/jdk-8u291-linux-x64.tar.gz && chmod -R 755 /opt/jdk1.8.0_291 && chown -R root:root /opt/jdk1.8.0_291]: exit code: 127
(base)
我已经尝试安装tar
或tar.x86_64
使用命令之前但仍然无法工作。我应该做什么来修复它?
答案1
将此行放入您的 docker 文件中,前您删除存储库:
RUN yum -y update && yum -y install wget vi openssl.x86_64 glibc.x86_64 tar tar.x86_64 inetutils-ping net-tools telnet which file