Installing Azure CLI in Dockerfile can't locate package azure-cli - azure

I'm trying to write a dockerfile that will install Azure CLI so that I can run CLI commands in bitbucket pipelines.
However the installation of the CLI always fails:
E: Unable to locate package azure-cli
The command '/bin/sh -c apt-get install azure-cli' returned a non-zero code: 100
Here is my dockerfile
FROM atlassian/default-image:latest
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl
RUN apt-get update
RUN apt-get install -y libssl-dev libffi-dev
RUN apt-get install -y python-dev
RUN apt-get install apt-transport-https lsb-release software-properties-common -y
ENV AZ_REPO $(lsb_release -cs)
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | tee /etc/apt/sources.list.d/azure-cli.list
RUN apt-key --keyring /etc/apt/trusted.gpg.d/Microsoft.gpg adv \
--keyserver packages.microsoft.com \
--recv-keys BC528686B50D79E339D3721CEB3E94ADBE1229CF
RUN apt-get install azure-cli
CMD ["/bin/bash"]

you need to do apt-get update after importing new package feed to get packages from that feed.

Related

Error installing containerd.io_1.6.9-1_amd64.deb on docker container

I'm trying to build a Docker container with the following commands in Dockerfile:
FROM python:3.6.2
RUN apt-get update && apt-get install make
RUN pip install -U pip setuptools wheel
RUN python -m pip install -r model-requirements.txt --python-version 3.6 --no-deps --target python6_pakages
# Installing docker-ce
RUN apt-get update
RUN apt install apt-transport-https ca-certificates curl software-properties-common -y --force-yes
RUN apt-get install -y gnupg --force-yes
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
RUN curl -O https://download.docker.com/linux/debian/dists/buster/pool/stable/amd64/containerd.io_1.6.9-1_amd64.deb
RUN apt install ./containerd.io_1.6.9-1_amd64.deb
RUN apt-cache policy docker-ce
RUN apt-cache search docker-ce
RUN apt install docker-ce -y
RUN apt-get install -y cron vim iputils-ping curl g++ unixodbc-dev gnupg supervisor
The problem us that when building process reaches the line RUN apt install ./containerd.io_1.6.9-1_amd64.deb I get errors like the following:
I have no idea why this is happening. I've double-checked the download URL and the package is successfully downloaded every time. Can you help me with this error?

How to run a docker command in Nodejs image

I wrote a node app, he can build and push docker image, but I hope to run him as a Docker container.
I can use the following method to run the docker command in the container, but this cannot be running the Node App.
docker run -i --rm --privileged docker:dind sh
Finally I found the answer:
FROM node
RUN apt-get update && apt-get install -y apt-transport-https \
ca-certificates curl gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable"
RUN apt-get update
RUN apt-get install -y docker-ce-cli
RUN apt-get install -y docker-compose
CMD ["node", "-v"]

Azure CLI in a Docker Container

I have an Ubuntu 18.04 Docker image that I need Azure CLI installed in. For a Docker image, it seems the preferred way is to use pip, however, I have other pip Azure libraries needed in the container that overlap with the CLI install and get blown away because Azure CLI requires older versions; then making it so I can't run my python scripts.
I have tried to use the script installer but that hasn't worked and errored out because I believe the install is interactive.
The last option I can find is the manual apt install, though I am not sure this is a correct way nor do I have a good idea of how to replicate that in a Dockerfile.
Is there a preferred/good way of getting Azure CLI in a container not using pip?
FROM ubuntu:18.04
RUN apt-get update && apt-get -y upgrade && \
apt-get -f -y install curl python3-pip python-pip && \
pip3 install --upgrade pip && \
pip2 install --upgrade pip && \
pip3 install azure-storage-blob==12.3.0 & \\
pip3 install azure-cli
I have a preference to use the package manager to install dependencies, it's why I will do something like that:
Add base dependencies for https repostory and curl
Add the gpg key and repository for the CLI
Add the CLI
This is the Dockerfile with thoses steps:
FROM ubuntu:18.04
RUN apt-get update && apt-get -y upgrade && \
apt-get -f -y install curl apt-transport-https lsb-release gnupg python3-pip python-pip && \
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \
CLI_REPO=$(lsb_release -cs) && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ ${CLI_REPO} main" \
> /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install -y azure-cli && \
rm -rf /var/lib/apt/lists/*
In addition, I clean up the apt cache by removing /var/lib/apt/lists. Tt reduces the image size, since the apt cache is not stored in a layer.
See: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#option-1-install-with-one-command
RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash && rm -rf /var/lib/apt/lists/*

yum in dockerfile - There are no enabled repos

I am having issues with installing python3 with yum in dockerfile. I did look on internet, I did try few things, not working. Its just small thing but not able to figure it out. When I try to build below docker file I do get error . I get error at line -
RUN yum install -y oracle-epel-release-el7
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
You can enable repos with yum-config-manager --enable <repo>
The docker file is below.
FROM openjdk:13-jdk-slim
ARG MAVEN_VERSION=3.6.3
ARG USER_HOME_DIR="/root"
ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
# Install prerequisites
RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y yum
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
# Install Python 3.6
RUN yum install -y oracle-epel-release-el7
RUN yum install -y python36
# Install AWS CLI
RUN pip3 install awscli
CMD ["/bin/bash"]
Why mix apt and yum? You're already using apt-get, just use it to install your python too:
apt-get install python3.6

Error when trying to install virtualbox-5.1

I'm trying to install Cuckoo (Ubuntu 64 bit) the commands that worked are:
$ sudo apt-get update
$ sudo apt-get install git -y
$ sudo apt-get install python python-pip python-dev libffi-dev libssl-dev -y
$ sudo apt-get install python-virtualenv python-setuptools -y
$ sudo apt-get install libjpeg-dev zlib1g-dev swig -y
$ sudo apt-get install mongodb -y
$ sudo apt-get install postgresql libpq-dev -y
$ echo deb http://http://download.virtualbox.org/virtualbox/debian xenial contrib | sudo tee -a /etc/apt/sources.list.d/virtualbox.list
$ wget -q https://https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
$ wget -q https://virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
and when I executed the following command:
$ sudo apt-get install virtualbox-5.1 -y
I got the following error:
Any help please on how to fix this error?
It would be better if you downloaded the .deb package from the website rather than using apt.

Resources