我想要一個具有docker
并terraform
安裝在其中的 ubuntu 的最小影像。
當我嘗試如下撰寫 Dockerfile 時,請建議我在撰寫 Dockerfile 時哪一個是最佳實踐:
FROM ubuntu
FROM docker
FROM hashicorp/terraform
RUN terraform --version
RUN docker --version
上述 Dockerfile 出現如下錯誤:
/bin/sh: docker: not found
The command '/bin/sh -c docker --version' returned a non-zero code: 127
或者
FROM ubuntu:latest AS ubuntu
RUN apt update && apt upgrade -y
RUN apt install unzip -y
COPY terraform.zip /home/
RUN unzip /home/terraform.zip
RUN mv terraform /usr/local/bin/
RUN terraform version
FROM docker
COPY --from=ubuntu /usr/local/bin/ /usr/local/bin
RUN terraform version
uj5u.com熱心網友回復:
這是一個快速而骯臟的解決方案,只是為了讓它作業 - 希望它可以幫助你。
Dockerfile:
# Choose your desired ubuntu version instead of :latest
FROM ubuntu:latest
RUN apt-get update
# Install docker other packages to get terraform setup
RUN apt install docker.io gnupg curl software-properties-common -y
# Setup terraform
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
RUN apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
RUN apt update
RUN apt install terraform
# Run the container
CMD [ "bash" ]
要運行的命令:
docker build . -t myapp
docker run -ti --entrypoint /bin/sh myapp
現在您在容器中:
# terraform -v
Terraform v1.2.8
on linux_amd64
# docker --version
Docker version 20.10.12, build 20.10.12-0ubuntu4
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/505838.html
標籤:GitLab Collective 码头工人 图片 GitLab 地形 dockerfile