[英]Unable to run aliyun-cli in Docker:stable container after installing it. Errors as command not found
I am unsure if stack overflow or system fault is the right stack exchange site but I'm going with stack overflow cause the alicloud site posted to add a tag and ask a question here.我不确定堆栈溢出或系统故障是否是正确的堆栈交换站点,但我将使用堆栈溢出导致发布的 alicloud 站点添加标签并在此处提问。
So.所以。 I'm currently building an image based on Docker:stable, that is an alpine distro, that will have aliyun-cli installed and available for use.
我目前正在构建一个基于 Docker:stable 的映像,这是一个 alpine 发行版,将安装 aliyun-cli 并可供使用。 However I am getting a weird error of Command Not Found when I'm running it.
但是,当我运行它时,我收到了一个奇怪的 Command Not Found 错误。 I have followed the guide here https://partners-intl.aliyun.com/help/doc-detail/139508.htm and moved the aliyun binary to /usr/sbin
我已按照此处的指南https://partners-intl.aliyun.com/help/doc-detail/139508.htm并将 aliyun 二进制文件移动到 /usr/sbin
Here is my Dockerfile for example例如,这是我的 Dockerfile
FROM docker:stable
RUN apk update && apk add curl
#Install python 3
RUN apk update && apk add python3 py3-pip
#Install AWS Cli
RUN pip3 install awscli --upgrade
# Install Aliyun CLI
RUN curl -L -o aliyun-cli.tgz https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.30-amd64.tgz
RUN tar -xzvf aliyun-cli.tgz
RUN mv aliyun /usr/bin
RUN chmod +x /usr/bin/aliyun
RUN rm aliyun-cli.tgz
However when i'm running aliyun (which can be auto-completed) I am getting this但是,当我运行 aliyun(可以自动完成)时,我得到了这个
/ # aliyun
sh: aliyun: not found
I've tried moving it to other bins.我试过把它移到其他垃圾箱。 Cding into the folder and calling it explicitly but still always getting a command not found.
进入文件夹并显式调用它,但仍然总是找不到命令。 Any suggestions would be welcome.
欢迎大家提出意见。
Did you check thisDockerfile ?你检查过这个Dockerfile吗?
Also why you need to install aws-cli
in the same image and why you will need to maintain it for your self when AWS providemanaged aws-cli
image.还有为什么您需要在同一个映像中安装
aws-cli
以及为什么当 AWS 提供托管aws-cli
映像时您需要自己维护它。
docker run --rm -it amazon/aws-cli --version
that's it for aws-cli image,but if you want in existing image then you can try这就是 aws-cli 图像,但如果你想要现有图像,那么你可以尝试
RUN pip install awscli --upgrade
DockerFile DockerFile
FROM python:2-alpine3.8
LABEL com.frapsoft.maintainer="Maik Ellerbrock" \
com.frapsoft.version="0.1.0"
ARG SERVICE_USER
ENV SERVICE_USER ${SERVICE_USER:-aliyun}
RUN apk add --no-cache curl
RUN curl https://raw.githubusercontent.com/ellerbrock/docker-collection/master/dockerfiles/alpine-aliyuncli/requirements.txt > /tmp/requirements.txt
RUN \
adduser -s /sbin/nologin -u 1000 -H -D ${SERVICE_USER} && \
apk add --no-cache build-base && \
pip install aliyuncli && \
pip install --no-cache-dir -r /tmp/requirements.txt && \
apk del build-base && \
rm -rf /tmp/*
USER ${SERVICE_USER}
WORKDIR /usr/local/bin
ENTRYPOINT [ "aliyuncli" ]
CMD [ "--help" ]
build and run构建并运行
docker build -t aliyuncli .
docker run -it --rm aliyuncli
output output
docker run -it --rm abc aliyuncli
usage: aliyuncli <command> <operation> [options and parameters]
<aliyuncli> the valid command as follows:
batchcompute | bsn
bss | cms
crm | drds
ecs | ess
ft | ocs
oms | ossadmin
ram | rds
risk | slb
ubsms | yundun
After a lot of lookup I found a github issue in the official aliyun-cli that sort of describes that it is not compatible with alpine linux because of it's not muslc compatible.经过大量查找后,我在官方 aliyun-cli 中发现了一个 github 问题,该问题描述了它与 alpine linux 不兼容,因为它不兼容 muslc。
Link here: https://github.com/aliyun/aliyun-cli/issues/54链接在这里: https://github.com/aliyun/aliyun-cli/issues/54
Following the workarounds there I build a multi-stage docker file with the following that simply fixed my issue.在解决方法之后,我构建了一个多阶段 docker 文件,其内容简单地解决了我的问题。
Dockerfile Dockerfile
#Build aliyun-cli binary ourselves because of issue
#in alpine https://github.com/aliyun/aliyun-cli/issues/54
FROM golang:1.13-alpine3.11 as cli_builder
RUN apk update && apk add curl git make
RUN mkdir /srv/aliyun
WORKDIR /srv/aliyun
RUN git clone https://github.com/aliyun/aliyun-cli.git
RUN git clone https://github.com/aliyun/aliyun-openapi-meta.git
ENV GOPROXY=https://goproxy.cn
WORKDIR aliyun-cli
RUN make deps; \
make testdeps; \
make build;
FROM docker:19
#Install python 3 & jq
RUN apk update && apk add python3 py3-pip python3-dev jq
#Install AWS Cli
RUN pip3 install awscli --upgrade
# Install Aliyun CLI from builder
COPY --from=cli_builder /srv/aliyun/aliyun-cli/out/aliyun /usr/bin
RUN aliyun configure set --profile default --mode EcsRamRole --ram-role-name build --region cn-shanghai
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.